If "^" appears in "[]", this expression does not match the characters appearing in "[]", such as "/[^a-z]/" does not match any lowercase letters! And the regular expression gives several default values for "[]", as follows:
' [: alnum:] ' matches any letter
Alphanumeric characters: ' [: Alpha:] ' and ' [:d igit:] '.
' [: 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 through 037, and 177 (' DEL '). In other character sets, this are the equivalent characters, if any.
' [:d igit:] ' matches any number
Digits: ' 0 1 2 3 4 5 6 7 8-9 '.
' [: Graph:] '
Graphical characters: ' [: alnum:] ' and ' [:p UNCT:] '.
' [: 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 '.
' [:p rint:] '
printable characters: ' [: alnum:] ', ' [:p unct:] ', and space.
' [:p unct:] ' matches any punctuation
Punctuation characters: '! "# $% & ' () * +,-. / : ; < = >? @ [ \ ] ^ _ ' { | } ~'.
' [: Space:] ' match spaces
Space Characters:tab, newline, vertical tab, form feed, carriage
return, and spaces.
' [: 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 16 binary digits
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] ', except the latter depends upon the ' C ' locale and the ASCII character Enco Ding, whereas the former is independent of locale and character set. (Note this brackets in this class names are part of the symbolic names, and must
be included into addition to the brackets delimiting the bracket expression.)
[$] The square brackets contain a range of matching characters, preceded by ^, that is, the specified character range is not matched.
$ereg represents a variable, which is the symbol of a variable, and the whole meaning of the formula is:
Ereg represents a string with all strings beginning with a letter and the second is a letter or a number.
Example:
Copy Code code as follows:
Preg_replace ("/" [[: alnum:]]|[ [: space:]]| [[:p UNCT:]]) +/u ", ', $string);