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}