August 1999
Intermediate to advanced
1488 pages
72h 53m
English
regexp.compile(pattern, flag)
The compile() method of the RegExp object compiles a regular expression object. The creation of the object takes pattern and flags parameters. The pattern is a valid regular expression. The flags are either or both g (global) and i (ignore case).
Listing 6.214 shows how to use the compile() method. A pattern is created using the RegExp constructor. It is then compiled using the compile method, and the result is displayed in the text area.
<html> <body> <script language="JavaScript"> <!–– Hide var myPat = new RegExp("jane", "i"); var newPat = myPat.compile(myPat); ... |
Read now
Unlock full access