MENU
RegExp
A regular expression is a pattern used to match characters in strings. It allows you to efficiently manipulate strings in various ways.
There are a few ways to initialize regular expressions, eg.:
var r1=/ab+c/i;
var r2=new RegExp('ab+c', 'i');
var r3=new RegExp(/ab+c/, 'i');
The second form is actually the most flexible, as it allows variables to be passed into the RegExp() as the pattern and flag strings. eg.
var p = "ab+c";
var f = "i";
var r2 = new RegExp(p+"def",f);