var pattern = /test/;
var pattern = new RegExp("test");
i (insensitive), g (global), and m (multi-line)
/test/ig
new RegExp("test","ig"))
? i: makes the regex case insenstive. So /test/i matches not only “test”, but also
“Test”, “TEST”, “tEsT”, and so on.
? g: matches all instances of the pattern, as opposed to the default of “local” which
matches only the first occurence. More on this later.
? m: allows matches across multiple lines as might be obtained from the value of a
textarea element.