Foreign language translation--javascript tutorial--regular expression--(4)

Source: Internet
Author: User
Tags modifiers

modifier

A regular may contain a modifier that can affect search results.

There are 3 modifiers in JS:

g: Find all results;

I: result ignoring case;

m: Multi-line matching mode;

Modifier is placed after the parameter, such as:/.../g.

A regular with no global modifier returns only the first matching value:

1 alert ("123". Match (/\d/))  //  ' 1 '

If there is a global modifier, all matching values will be returned:

1 alert ("123". Match (/\d/g))  //  ' 1 ', ' 2 ', ' 3 '

multiple modifiers are also possible. For example: ignoring the global match of the case:

1 alert ("Smile a Smile". Match (/smile/gi))  //  ' Smile ', ' Smile '

A multiline match is later involved.

Foreign language translation--javascript tutorial--regular expression--(4)

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.