Regular expression is regular expression, it seems that English is better than Chinese understand more, is to check expression characters do not conform to the rules!! Regular expressions have a very powerful and complex object RegexpInJavascript1.2Version above provided.
Let's look at an introduction to regular expressions:
Regular expression objects are used to standardize an expression of a specification (that is, an expression character that does not meet a specific requirement, such as an email address format, etc.), and it has properties and methods for checking whether the given string conforms to the rules.
In addition, the properties of the individual regular expression objects that you set up with the RegExp constructor have predefined static properties of regular expression objects that you can use at any time.
Core objects:
In JavaScript 1.2, NES more than 3.0 versions are available.
After the JavaScript 1.3 version added the Tosource method.
To establish a method:
Text formatting or regexp constructor functions.
Text formatting uses the following format:
/pattern/flags/Mode/tag
The constructor function method uses the following methods:
New RegExp ("pattern" [, "Flags"]) is new REGEXP ("mode" [, "tag"])
Parameters:
Pattern (Mode)
Text that represents the regular expression
Flags (tags)
If you specify this item, flags can be one of the following denominations:
G:global match (full set matching)
I:ignore case (ignoring capitalization)
Gi:both Global Match and ignore case (matches all possible values, also ignores capitalization)
Note: The parameters in the text format do not use quotation marks, and constructor function parameters are marked with quotation marks. So the following expression establishes the same regular expression:
/ab+c/i
New RegExp ("Ab+c", "I")
Describe:
When using constructors, it is necessary to use normal string avoidance rules (adding leading characters in a string).
For example, the following two statements are equivalent:
Re = new RegExp ("\\w+")
Re =/\w+/