Detailed expression 1

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.