What does the “Nothing to repeat” error mean when using a regex in javascript?
You need to double the backslashes used to escape the regular expression special characters. However, as @Bohemian points out, most of those backslashes aren’t needed. Unfortunately, his answer suffers from the same problem as yours. What you actually want is: The backslash is being interpreted by the code that reads the string, rather than passed …