Summary of differences between regular expressions (parentheses), [brackets], {curly braces}

Source: Internet
Author: User

Summary of differences between regular expressions (parentheses), [brackets], {curly braces} Submission: Junjie font: [Increase decrease] Type: Reproduced this article mainly introduces the regular expression (parentheses), [brackets], {curly braces} of the difference between the summary, this article with (\s*) [\s*]{\s*} do examples, the need for friends can refer to the next

The () [] {} of the regular expression has different meanings.

() is to extract a matching string. There are several () in the expression that have several corresponding matching strings.

(\s*) A string that represents a contiguous space.

[] is the range of characters that defines the match. For example [a-za-z0-9] means that the corresponding position of the character to match the English characters and numbers. [\s*] denotes a space or * number.

{} is generally used to indicate the length of the match, such as \s{3} to match three spaces, and \s[1,3] to match one to three spaces.

(0-9) match ' 0-9′ itself. [0-9]* matches the number (note that there is *, can be empty) [0-9]+ matches the number (note that there is a +, can not be empty) {1-9} notation error.

[0-9] {0,9} represents a numeric string of length 0 to 9.

For example, filter content in PHP with numbers or spaces

Copy CodeThe code is as follows:
Preg_replace ("/\d{1,}\s{0,1}/", "xxxxxxxx", $signaturecontent);
Source: >  

From for notes (Wiz)

Summary of differences between regular expressions (parentheses), [brackets], {curly braces}

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.