Special symbols for modifying the number of matches

Source: Internet
Author: User

The expression mentioned in the previous essay, whether it is an expression that matches only one character, or an expression that matches any of several characters, can only be matched once. If you use an expression plus a special symbol that modifies the number of matches, you can repeat the match without repeating the expression.

Use the method : The number modifier is placed behind the decorated expression. For example: "[BCD][BCD]" can be written as "[Bcd]{2}".

Example 1:

Expression "/d+/.? /d* "in matching It costs $12.5", the result of the match was: "12.5", the match to the position is: start at 10, end at 14.

Example 2:

When the expression "Go{2,8}gle" matches the "Ads by Goooooogle", the result of the match is: "Goooooogle", the match to the position is: start at 7, end at 17.

Special symbols for modifying the number of matches

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.