Skip to content

Instantly share code, notes, and snippets.

@lior-amsalem
Created October 17, 2021 18:49
Show Gist options
  • Save lior-amsalem/7528dbc2747413e3dbc1352c2e600ffd to your computer and use it in GitHub Desktop.
Save lior-amsalem/7528dbc2747413e3dbc1352c2e600ffd to your computer and use it in GitHub Desktop.
Strip comment #test
/**
var result = solution("apples, pears # and bananas\ngrapes\nbananas !apples", ["#", "!"])
// result should == "apples, pears\ngrapes\nbananas"
**/
function solution(input, markers) {
return input.replace(new RegExp('(\\s?['+markers.join('?') + '?' + '\-?]\\s?)(.*)','gm'),'');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment