检查字串是否符合给定的正则表达式.
| [ ... ] |
Match any character in the set. e.g. [aeiou] matches any lower-case vowel. A contiguous set can be defined using a dash between the starting and ending characters. e.g. [a-z] matches any lower case character. To include a dash (-) in a set, use it as the first or last character of the set. To include a closing bracket in a set, use it as the first character of the set. e.g. [][] will match either [ or ]. Note that special characters do not retain their special meanings inside a set, with the exception of \\, \^, \-,\[ and \] match the escaped character inside a set. |
| [^ ... ] |
Match any character not in the set. e.g. [^0-9] matches any non-digit. To include a caret (^) in a set, put it after the beginning of the set or escape it (\^). |
| [:class:] |
Match a character in the given class of characters. Valid classes are: alpha (any alphabetic character), alnum (any alphanumeric character), lower (any lower-case letter), upper (any upper-case letter), digit (any decimal digit 0-9), xdigit (any hexadecimal digit, 0-9, A-F, a-f), space (any whitespace character), blank (only a space or tab), print (any printable character), graph (any printable character except spaces), cntrl (any control character [ascii 127 or <32]) or punct (any punctuation character). So [0-9] is equivalent to [[:digit:]]. |
| [^:class:] |
Match any character not in the class, but only if the first character. |
| ( ... ) |
Group. The elements in the group are treated in order and can be repeated together. e.g. (ab)+ will match "ab" or "abab", but not "aba". A group will also store the text matched for use in back-references and in the array returned by the function, depending on flag value. |
| (?#....) |
comment (not nestable). |
| (?i) |
Case-insensitivity flag. This does not operate as a group. It tells the regular expression engine to do case-insensitive matching from that point on. |
| (?-i) |
(default) Case-sensitivity flag. This does not operate as a group. It tells the regular expression engine to do case-sensitive matching from that point on. |
| (?: ... ) |
Non-capturing group. Behaves just like a normal group, but does not record the matching characters in the array nor can the matched text be used for back-referencing. |
| (?i: ... ) |
Case-insensitive non-capturing group. Behaves just like a non-capturing group, but performs case-insensitive matches within the group. |
| (?-i: ... ) |
Case-sensitive non-capturing group. Behaves just like a non-capturing group, but performs case-sensitive matches within the group. |
| (?J) |
allow duplicate names. |
| (?m) |
^ and $ match newlines within data. |
| (?s) |
. 匹配任意字符,包括换行. (默认 "." 不匹配换行) |
| (?U) |
Invert greediness of quantifiers. |
| (?x) |
忽略空白区域和 # 注释. |
| (?-...) |
unset option(s). |
| . |
匹配任何的单字符 (除换行以外).. |
| | |
或(or). 可以匹配|前的字符也可以匹配|之后的字符. |
| \ |
退出一个特殊字符 (让它匹配实际字符) 或者引用一个特殊字符类型 (见下文).. |
| \\ |
匹配一个真实的反斜线 (\). |
| \a |
闹铃,即字符 BEL (chr(7)). |
| \A |
只匹配字符串开始. |
| \b |
匹配一个单词范围. |
| \B |
匹配一个非单词范围. |
| \c |
匹配一个控制字符, 基于下一字符进行计算. 例如, \cM 匹配 ctrl-M. |
| \d |
匹配任何的数字 (0-9). |
| \D |
匹配任何的非数字. |
| \e |
匹配一个退出符 (chr(27)). |
| \E |
end case modification. |
| \f |
匹配进纸符 (chr(12)). |
| \G |
first matching position in subject. |
| \h |
任何的水平空白字符. |
| \H |
任何不是水平的空白字符. |
| \n |
匹配换行符 (@LF, chr(10)). |
| \K |
reset start of match. |
| \N |
a character that is not a newline |
| \Q |
quote (disable) pattern metacharacters till \E. |
| \r |
匹配一个回车符 (@CR, chr(13)). |
| \R |
a newline sequence. |
| \s |
匹配任何的空白字符: Chr(9) 到 Chr(13).包括:水平制表符,换行,垂直列表符,换页,回车以及标准空格 ( Chr(32) ). |
| \S |
匹配任何的非空白的字符. |
| \t |
匹配一个制表符 (chr(9)). |
| \v |
任何的垂直空白字符. |
| \V |
任何一个不是垂直空白字符的字符. |
| \w |
匹配任何的"单词" 字符: a-z, A-Z, 0-9 或下划线 (_). |
| \W |
匹配任何的非"单词"字符. |
| \ddd |
Match character with octal code ddd, or backreference if found. Match the prior group number given exactly. For example, ([:alpha:])\1 would match a double letter. |
| \xhh |
匹配指定的字符,用字符的的十六进制表示.hh为两位 |
| \x{hhh..} |
匹配指定的字符,用字符的的十六进制表示.hhh..至少为三位 |
| \z |
只匹配字符串结束. |
| \Z |
只匹配字符串结束,或者换行之前. |