What are the special characters "[]" and "" in PHP regular expressions? What are the specific operations? Why are they special characters? Let's take a look at the specific introduction.
There are two important special characters: "[]". They can match any character in "[]", for example, "/[az]/" can match a single character "a" or "z "; if you change the expression above to "/[a-z]/", you can match any single lowercase letter, such as "a" and "B.
For PHP Regular Expression special characters "[]":
If "^" is displayed in "[]", this expression does not match the characters in, for example, "/[^ a-z]/" does not match any lower-case letters! In addition, the regular expression provides the default values:
◆ [: Alpha:]: match any letter
◆ [: Alnum:]: match any letter or number
◆ [: Digit:]: match any number
◆ [: Space:]: matches space characters
◆ [: Upper:]: match any uppercase letter
◆ [: Lower:]: match any lowercase letter
◆ [: Punct:]: match any punctuation marks
◆ [: Xdigit:]: match any hexadecimal number
PHP Regular Expression special character "":
The following special characters indicate the following meanings after the escape symbol "" is escaped:
◆ S: match a single space character
◆ S: Used to match all characters except a single space character.
◆ D: Used to match numbers from 0 to 9, which is equivalent to "/[0-9]/".
◆ W: Used to match letters, numbers or underscores, equivalent to "/[a-zA-Z0-9 _]/".
◆ W: Used to match all the characters that do not match w, equivalent to "/[^ a-zA-Z0-9 _]/".
◆ D: Used to match any non-decimal numeric characters.
. ◆: Used to match all characters except line breaks. If the modifier "s" is used, "." can represent any character.
We will introduce you to the introduction of special characters in PHP regular expressions. I hope that will help you understand and master the use of special characters in PHP regular expressions.