I have created the following RegExp object:
RegExp(/_if|_elseif|_else|_while|_store/, "g")
I need to match either of the pipe delim strings. The above method works in chrome. But the IE11 throws error saying some syntax error.
That's because the RegExp constructor in IE11 only takes a string as its first argument, and not a regular expression literal:
RegExp("_if|_elseif|_else|_while|_store", "g")
^ ^
Alternatively, you can simply add the g flag to the end of your regular expression literal and drop the constructor notation altogether:
/_if|_elseif|_else|_while|_store/g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With