The regular expression is a regular expression. It seems that English is better understood than Chinese, that is, the regular expression is checked for non-conforming characters !! Regular expressions have a very powerful and complex object. Regexp , In Javascript1.2 Available in versions or later. Let's take a look at the introduction of regular expressions:
A regular expression object is used to regulate a standard expression (that is, the expression operator does not meet specific requirements, such as whether it is an email address format or not ), it has the attributes and methods used to check whether the given string meets the rules.
In addition, the attributes of individual regular expression objects created using the Regexp constructor have pre-defined static attributes of Regular Expression objects, and you can use them at any time.
Core objects:
Available in Javascript 1.2 and NES 3.0 and later versions.
The tosource method is added in Versions later than JavaScript 1.3.
CreateCubeMethod:
Text format or Regexp constructor function.
The text format is as follows:
/Pattern/flags:/mode/flag
The constructor function method is as follows:
New Regexp ("pattern" [, "Flags"]) is new Regexp ("Mode" [, "flag"])
Parameters:
Pattern)
Indicates the text of a regular expression.
Flags)
If this option is specified, flags can be one of the following nominal values:
G: Global match (exact match)
I: Ignore case (case insensitive)
GI: both global match and ignore case (matching all possible values, Case Insensitive)
Note: Do not Mark parameters in text format with quotation marks, while parameters in constructors must be marked with quotation marks. Therefore, the following expression creates the same regular expression:
/AB + C/I
New Regexp ("AB + C", "I ")
Description:
When using constructor, you must use a normal string to avoid rules (adding the leading character \ To the string.
For example, the following two statements are equivalent:
Re = new Regexp ("\ W + ")
Re =/\ W +/
Source: http://www.livebaby.cn/blog/u/meil/archives/2007/322.html