0

I use a regexp in my javascript code, that searches for a tag with its "less than" and "more than" brackets :

html = html.replace(/(\<\/ul\>\n\<ul\>)/gm,'');

It works perfectly, but jshint tells me "Unexpected escaped character '<' in regular expression."

My question is : is there a good reason to escape them ?

Sly
  • 361
  • 2
  • 9
  • 3
    Why do you escape `<` and `>` in the first place? They are not special regex metacharacters in JS regex flavor. – Wiktor Stribiżew Dec 22 '16 at 11:28
  • 1
    "is there a good reason to escape them " - yes, there is, if you're going to use the same regex with other dialects (php, python etc). e.g. a config file that will read both in backend and frontend. – georg Dec 22 '16 at 12:19

0 Answers0