There are POSIX and PCRE regular expressions in php. Regular expressions are flexible in php. Let's talk about POSIX expressions today. Below are some important knowledge points I have listed. (1) the delimiters & quot; ^ & quot; and & quot; $ & quot; indicate start and end respectively. NOTE: & quot; ^ & quot;
There are POSIX and PCRE regular expressions in php. Regular expressions are flexible in php.
Let's talk about POSIX expressions today. Below are some important knowledge points I have listed.
(1) the delimiters "^" and "$" indicate start and end respectively. Note: Once "^" is used with [], it indicates taking non-matching.
(2) POSIX quantifiers include *, +, and ,? , {N}, {n,}, and {n, m}
(3) square brackets [] such as ^ [a-z] [0-9] $ matching t6
(4) pre-defined character clusters. for example, [[: alpha:] indicates uppercase/lowercase letters.
(5) applications such as ereg_replace () and split ()
The following are detailed knowledge points:
\
It is used to disable the special meaning of subsequent characters. It is sometimes used to reverse open the special meaning of subsequent characters.
.
(Point) matches any single character, except NULL.
*
Match any number of characters (can be 0 ). In the case of ERE, this prefix is a regular expression, as shown in figure.*Represents the length of matching any character. But for BRE,*Placed in the first character of the regular expression does not have any special meaning.
^
(Remove font size) matches an empty string at the beginning of the line or the start of the string.ERE: It has a special meaning in any position;BRE: It has this special meaning only at the beginning of the regular expression.
$
Match the null string at the end of the row.ERE: It has a special meaning in any position;BRE: It has this special meaning only at the end of the regular expression.
[...]
The square brackets expression matches any character in the square brackets. A hyphen (-) indicates the range of consecutive characters. ^ The first character in square brackets has a reverse meaning: it indicates matching any character that is not in the list (within square brackets. It is considered as a part of the list as the first character or ending square brackets. All other meta characters are also part of the list.
The following onlyBRE:
\ {N-m}
An interval expression that matches the number of times that a single character returns before it.\ {N \}Refers to repeated n times;\ {N ,\}This means that at least n times of repetition occurs, while\ {N, m}To reproduce n to m times.
\(\)
Set\ (And \)The Inter-mode is stored in a special "reserved space ". Up to nine independent sub-modes can be stored in a single mode. For example, \ (AB \). * \ 1 indicates two copies matching the AB combination.
\ N
Repeat\ (And \)The nth submode in square brackets is the current vertex mode. N is a number ranging from 1 to 9, starting from left.
The following onlyERE:
{N, m}
It is the same as \ {n, m \} of BRE, but there is no backslash before square brackets.
+
Matches one or more instances of the preceding regular expression.
?
Matches the first regular expression with 0 or 1 instance.
|
Match with the regular expression before or after the symbol.
()
Matches the regular expression Group enclosed by square brackets.
POSIX square brackets:
1. Character set
[:And:]
2. sort symbols
[.And.]
3. equivalent character set
[=And=]
The details are as follows:
[: Alnum:]
Numeric characters
[: Alpha:]
Letter
[: Blank:]
Space and positioning characters
[: Cntrl:]
Control characters
[: Digit:]
Numeric characters
[: Graph:]
Non-space characters
[: Lower:]
Lowercase letter
[: Print:]
Printable characters
[: Punct:]
Punctuation character
[: Space:]
White space characters
[: Upper:]
Uppercase/lowercase letters
[: Xdigit:]
Hexadecimal number
Regular expressions in php are worth studying. of course, they are very powerful.
In addition, the PCRE regular expression is more powerful and will be displayed for you later on in php!