Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • is it the complete example code ? if not do share, and also paste the error / exception traceback Commented Jun 22, 2016 at 7:13
  • 1
    No sense in fighting with escaping if you can do it more simply. Keep your special strings in an array, and build the regex dynamically using the escapeRegExp function found in Escape string for use in Javascript regex. You can easily map each special string with the escapeRegExp and then join all of the escaped strings with .join("|") to get a properly constructed regexp. It'll keep your list of strings in an easy to maintain state, in case you want to add more. Commented Jun 27, 2016 at 3:42