Document directory
Keywords: javascript Regexp test exec compile Regexp object three methods are available:
1. Test ()Returns true or false for the specified matching mode in the string:
VaR patt1 = new Regexp ("e"); document. write (patt1.test ("the best things in life are free"); because the character string contains the letter "E", the output of the above Code will be:
True2. Exec ()Method to retrieve the specified value in the string. The returned value is the result array found. If no matching is found, null is returned. Example:
VaR patt1 = new Regexp ("S"); patt1.exec ("the best things in life are free ")
3. complie ()
The compile () method is used to change Regexp.
Compile () can either change the search mode or add or delete the second parameter.
Example:
VaR patt1 = new Regexp ("e"); document. write (patt1.test ("the best things in life are free"); patt1.compile ("D"); document. write (patt1.test ("the best things in life are free "));