Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Between Markers solution in Uncategorized category for Between Markers by Elena_Korljukova
import assert from "assert";
function betweenMarkers(text: string, begin: string, end: string): string {
var begin_ = text.includes(begin) ? text.indexOf(begin) + begin.length : 0;
var end_ = text.includes(end) ? text.indexOf(end) : text.length;
return text.slice( begin_ , end_);
}
console.log('Example:')
console.log(betweenMarkers('What is >apple<', '>', '<'), 'apple')
console.log(betweenMarkers('No[/b] hi', '[b]', '[/b]'));
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!");
June 20, 2020