contents   index   previous   next



RegExp compile()

syntax:

regexp.compile(pattern[, attributes])

where:

pattern - a string with a new regular expression pattern to use with this RegExp object.

 

attributes - a string with the new attributes for this RegExp object.

 

return:

void.

 

description:

This method changes the pattern and attributes to use with the current instance of a RegExp object. An instance of a RegExp object may be used repeatedly by changing it with this method.

 

If the attributes string is supplied, it must contain one or more of the following characters or be an empty string "":

 

i - sets the ignoreCase property to true

g - sets the global property to true

m - set the multiline property to true

 

see:

RegExp(), Regular expression syntax

 

example:

var regobj = new RegExp("now");

// use this RegExp object

regobj.compile("r*t");

// use it some more

regobj.compile("t.+o", "ig");

// use it some more

 


RegExp exec()