Here’s one way to get that error…
If you declare a RegExp as a variable outside of a function, such as:
var vpattern = ".*";
var vmodifier = "i";
var vregexp = new RegExp(vpattern,vmodifier);
you’ll get that error. The regexp works, it just generates an error for some reason.
There could be other reasons for this error, too.