JS Regular notes

Source: Internet
Author: User

instanceof REGEXP

REGEXP is a class in JS, similar to an array. However, this creation method does not specify the expression content

var re=new RegExp ();

The simplest regular expression that will match the letter A
Re=new RegExp ("a");
//Overloaded constructor whose second parameter specifies that the case is not case-sensitive
Re=new RegExp ("A", "I");

Among them, for the second parameter, optional parameters, including three kinds:

    • G: Full text Search;
    • I: Case insensitive;
    • M: Multi-line search;

The more common rules for creating regular expressions are: the way literals are declared.

var re=/a/i; //Its effects are the same: Re=new RegExp ("A", "I"), and more commonly used.

Regular expression methods:

    • Test method: Returns the Boolean type. It indicates whether the pattern is included in the string being searched. Returns true if present, otherwise false;
    • Exec method: Uses the regular expression pattern to look in the string and returns an array that conforms to the regular expression pattern;

Regular Expression properties:

    • Source property: Returns the text content of the regular expression. Read-only;

A String that matches the regular expression method:

    • Match method: Finds the matching of one or more regular expressions, similar to the Exec method, returns an array


JS Regular notes

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.