| compile() The compile() method is used to compile the regular expression. The pattern to be searched through (stringName - see syntax), and the flags to be used are expressed as the parameters to the compile method. The flags may be "g" (lowercase only) for global search, and "i" (again, lowercase only) for ignore case. syntax: regExpName.compile(stringName, flags) EXAMPLE regExpSearch = new RegExp("the"); regExpArray = regExpSearch.compile(regExpSearch); function getRegExp() { document.form.textBox.value = regExpArray; } Within the BODY of your document, insert the following: In the above example, we first create an instance of the RegExp object, called regExpSearch, which is searching for the word "the". We then create an array which has as its contents the compilation of regExpSearch. A function is then used to get the results of the search from a text box and input button within the body of the document. When the button is clicked, the onClick event handler runs the getRegExp() function, returning the result. |