JSLint and JSHint (prior to version 1.0.0) will throw the "A regular expression literal can be confused with '/='" error when they encounter a regular expression literal that begins with the = character. In the following example we attempt to assign a regular expression literal to match the string "=1" to the variable x:
This error is raised to highlight a potentially confusing piece of code. Your code will run fine if you do not fix this error, but it may be confusing to others, especially at first glance to someone quickly searching through your script.
This ambiguity is not a problem because the parser should always be able to differentiate between the two uses. However, you can see why the regular expression example at the top of this page could cause initial confusion.
To solve this issue, you can simply escape the = character in the regular expression. This will behave in exactly the same way but since the = character is no longer the first, the error is not raised:
Alternatively, you can use the RegExp constructor, which removes the need for the delimiting / characters: