xxxxxxxxxx
function escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
xxxxxxxxxx
/*The most commonly-used special characters are \n and \t, which are the
newline and tab characters, respectively. They work as you would expect.*/
console.log("A message\nbroken across lines,\n\tand indented");
//A message
//broken across lines,
// and indented