0

I am taking user generated strings and matching/replacing them as needed. Something to the tune of

new RegExp(str,'gi')

If a user types in something like [Hey or ] or something that would otherwise normally need to be escaped the code breaks. How can I work around this? is there a clean means of doing it?

chris
  • 36,115
  • 52
  • 143
  • 252
  • 1
    take a look at http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript – Turo May 27 '16 at 17:29
  • Thank you, I did.. it helped me over all solve the issue I was having. Don't know how many posts I went through prior to asking that didn't help.. anyway, thanks again! – chris May 29 '16 at 03:12

0 Answers0