字符 | 描述 | matches |
---|---|---|
. | not newline | any character except line terminators (LF, CR, LS, PS). |
\t | tab (HT) | a horizontal tab character (same as\u0009). |
\n | newline (LF) | a newline (line feed) character (same as\u000A). |
\v | vertical tab (VT) | a vertical tab character (same as\u000B). |
\f | form feed (FF) | a form feed character (same as\u000C). |
\r | carriage return (CR) | a carriage return character (same as\u000D). |
\cletter | control code | a control code character whose code unit value is the same as the remainder of dividing the code unit value of letter by 32. 例如:\ca与...相同\u0001, \cbthe same as\u0002, and so on... |
\xhh | ASCII character | a character whose code unit value has an hex value equivalent to the two hex digits hh. 例如:\x4c与...相同L类型,或\x23the same as#. |
\uhhhh | unicode character | a character whose code unit value has an hex value equivalent to the four hex digits hhhh. |
\0 | null | a null character (same as\u0000). |
\int | backreference | the result of the submatch whose opening parenthesis is the int-th (int shall begin by a digit other than0). See groups below for more info. |
\d | digit | a decimal digit character (same as[[:digit:]]). |
\D | not digit | any character that is not a decimal digit character (same as[^[:digit:]]). |
\s | whitespace | a whitespace character (same as[[:space:]]). |
\S | not whitespace | any character that is not a whitespace character (same as[^[:space:]]). |
\w | word | an alphanumeric or underscore character (same as[_[:alnum:]]). |
\W | not word | any character that is not an alphanumeric or underscore character (same as[^_[:alnum:]]). |
\character | character | the character character as it is, without interpreting its special meaning within a regex expression. Any character can be escaped except those which form any of the special character sequences above. Needed for^ $ \ . * + ? ( ) [ ] { } | |
[类] | character class | the target character is part of the class (see character classes below) |
[^类] | negated character class | the target character is not part of the class (see character classes below) |
|
|
字符 | times | effects |
---|---|---|
* | 0 or more | The preceding atom is matched 0 or more times. |
+ | 1 or more | The preceding atom is matched 1 or more times. |
? | 0 or 1 | The preceding atom is optional (matched either 0 times or once). |
{int} | int | The preceding atom is matched exactly int times. |
{int,} | int or more | The preceding atom is matched int or more times. |
{min,max} | between min and max | The preceding atom is matched at least min times, but not more than max. |
字符 | 描述 | effects |
---|---|---|
(subpattern) | Group | Creates a backreference. |
(?:subpattern) | Passive group | Does not create a backreference. |
字符 | 描述 | condition for match |
---|---|---|
^ | Beginning of line | Either it is the beginning of the target sequence, or follows a line terminator. |
$ | End of line | Either it is the end of the target sequence, or precedes a line terminator. |
\b | Word boundary | The previous character is a word character and the next is a non-word character (or vice-versa). Note: The beginning and the end of the target sequence are considered here as non-word characters. |
\B | Not a word boundary | The previous and next characters are both word characters or both are non-word characters. Note: The beginning and the end of the target sequence are considered here as non-word characters. |
(?=subpattern) | Positive lookahead | The characters following the assertion must match subpattern, but no characters are consumed. |
(?!subpattern) | Negative lookahead | The characters following the assertion must not match subpattern, but no characters are consumed. |
character | 描述 | effects |
---|---|---|
| | Separator | Separates two alternative patterns or subpatterns. |
类 | 描述 | 说明 |
---|---|---|
[:classname:] | character class | Uses the regex traits' isctype member with the appropriate type gotten from applying lookup_classname member on classname for the match. |
[.classname.] | collating sequence | Uses the regex traits' lookup_collatename to interpret classname. |
[=classname=] | character equivalents | Uses the regex traits' transform_primary of the result of regex_traits::lookup_collatename for classname to check for matches. |
类 | 描述 | equivalent (with regex_traits, default locale) |
---|---|---|
[:alnum:] | alpha-numerical character | isalnum |
[:alpha:] | 字母字符 | isalpha |
[:blank:] | 空白字符 | isblank |
[:cntrl:] | 控制字符 | iscntrl |
[:digit:] | 十进制数字字符 | isdigit |
[:graph:] | 具有图形表示的字符 | isgraph |
[:lower:] | 小写字母 | islower |
[:print:] | 可打印字符 | isprint |
[:punct:] | punctuation mark character | ispunct |
[:space:] | whitespace character | isspace |
[:upper:] | 大写字母 | isupper |
[:xdigit:] | 十六进制数字字符 | isxdigit |
[:d:] | 十进制数字字符 | isdigit |
[:w:] | word character | isalnum |
[:s:] | whitespace character | isspace |