contents   index   previous   next

Regular expression literals

Regular expression literals delimit a regular expression pattern. The literals are a slash "/" at the beginning of some characters and a slash "/" at the end of the characters. These regular expression literals operate in the same way as quotation marks do for string literals. The following two lines of code accomplish the same thing, namely, they define and create an instance of a RegExp object:


var re = /^THEY/;

var re = new RegExp("^THEY");


and so do the following two lines:


var re = /^THEY/i;

var re = new RegExp("^THEY", "i");

Regular expression characters