Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Between Markers by pokosasa
import assert from "assert";
function betweenMarkers(text: string, begin: string, end: string): string {
return text.slice((begin + text).lastIndexOf(begin), (text + end).indexOf(end));
}
console.log('Example:')
console.log(betweenMarkers('What is >apple<', '>', '<'), 'apple')
assert.equal(betweenMarkers('What is >apple<', '>', '<'), 'apple')
assert.equal(betweenMarkers("My new site",
"", ""), 'My new site')
assert.equal(betweenMarkers('No[/b] hi', '[b]', '[/b]'), 'No')
assert.equal(betweenMarkers('No [b]hi', '[b]', '[/b]'), 'hi')
assert.equal(betweenMarkers('No hi', '[b]', '[/b]'), 'No hi')
assert.equal(betweenMarkers('No ', '>', '<'), '')
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
March 14, 2021
Comments: