You can create regex's in multiple ways. Using the new RegExp
-constructor:
var re = new RegExp("[a-z]", "ig") //(string pattern, string modifiers)
Or using the regex literal notation:
var re = /[a-z]/ig; // /pattern/modifiers
You have mixed the two.