If "^" is displayed in "[]", this expression does not match the characters in, for example, "/[^ a-z]/" does not match any lower-case letters! The regular expression provides the following default values:
'[: Alnum:]' matches any letter
Alphanumeric characters: '[: alpha:]' and '[: digit:]'.
'[: Alpha:]' matches any letter or number
Alphabetic characters: '[: lower:]' and '[: upper:]'.
'[: Blank:]'
Blank characters: space and tab.
'[: Cntrl:]'
Control characters. In ASCII, these characters have octal codes 000 through 037, and 177 ('del '). In other character sets, these are the equivalent characters, if any.
'[: Digit:]' matches any number
Digits: '0 1 2 3 4 5 6 7 8 9 '.
'[: Graph:]'
Graphical characters: '[: alnum:]' and '[: punct:]'.
'[: Lower:]' matches any lowercase letter
Lower-case letters: 'a B c d e f g h I j k l m n o p q r s t u v w
X y Z '.
'[: Print:]'
Printable characters: '[: alnum:]', '[: punct:]', and space.
'[: Punct:]' matches any punctuation marks
Punctuation characters :'! "# $ % & '() * +,-./:; <=>? @ [\] ^ _ '{| }~ '.
'[: Space:]' matches the space character
Space characters: tab, newline, vertical tab, form feed, carriage
Return, and space.
'[: Upper:]' matches any uppercase letter
Upper-case letters: 'a B C D E F G H I J K L M N O P Q R S T U V W
X y Z '.
'[: Xdigit:]' matches any hexadecimal number
Hexadecimal digits: '0 1 2 3 4 5 6 7 8 9 a B c d e f a B c d e F '.
For example, '[[: alnum:]' means '[0-9A-Za-z]', doesn't the latter depends upon the 'C' locale and the ASCII character encoding, whereas the former is independent of locale and character set. (Note that the brackets in these class names are part of the symbolic names, and must
Be authorized ded in addition to the brackets delimiting the bracket expression .)
[$] Square brackets contain a matching character range. Adding a ^ in front of it indicates that the specified character range does not match.
$ Ereg indicates a variable, that is, $ indicates a variable. The overall meaning of this formula is:
Ereg indicates a string with a letter starting with a letter and a second character or number.
Example:
Copy codeThe Code is as follows: preg_replace ("/([[: alnum:] | [[: space:] | [[: punct:]) +/U ",'', $ string );