Regexp Syntax Summary
http://www.greenend.org.uk/rjk/tech/regexp.html
| String | GNU grep | BRE (grep) | ERE (egrep) | GNU Emacs | Perl | Python | Tcl | ||
| . | Any character | Any character except \0 | Any character except \n | Any character | |||||
| [...] | Bracket Expression | Character Set | Character Class | Bracket Expression | |||||
| \(re\) | Subexpression | Grouping | |||||||
| re\{...\} | Match re multiple times | Match re multiple times | |||||||
| (re) | Subexpression | Grouping | |||||||
| re{...} | Match re multiple times | Match re multiple times | |||||||
| re{...}? | Nongreedy {} | ||||||||
| \digit | Back-reference | ||||||||
| ^ | Start of line | ||||||||
| $ | End of line | ||||||||
| re? | re 0 or 1 times | ||||||||
| re* | re 0 or more times | ||||||||
| re+ | re one or more times | ||||||||
| l|r | l or r | l or r | |||||||
| *? | Non-greedy * | ||||||||
| +? | Non-greedy + | ||||||||
| ?? | Non-greedy ? | ||||||||
| \A | Start of string | ||||||||
| \b | Either end of word | Either end of word | |||||||
| \B | Not either end of word | Not either end of word | Synonym for \ | ||||||
| \cC | Any in category C | ||||||||
| \CC | Any not in category C | ||||||||
| \C | Any octet | ||||||||
| \d | Digit | ||||||||
| \D | Non-digit | ||||||||
| \G | At pos() | ||||||||
| \m | Start of word | ||||||||
| \M | End of word | ||||||||
| \pproperty \p{property} |
Unicode property | ||||||||
| \Pproperty \P{property} |
Not unicode property | ||||||||
| \sC | Any with syntax C | ||||||||
| \SC | Any with syntax not C | ||||||||
| \s | Whitespace | ||||||||
| \S | Non-whitespace | ||||||||
| \w | Same as [[:alnum]] | Same as \sw | Alphanumeric and _ | ||||||
| \W | Same as [^[:alnum]] | Same as \Sw | Not alphanumeric or _ | ||||||
| \X | Combining sequence | ||||||||
| \y | Either end of word | ||||||||
| \y | Not either end of word | ||||||||
| \Z | End of string/last line | End of string | |||||||
| \z | End of string | ||||||||
| \` | Start of buffer/string | ||||||||
| \' | End of buffer/string | ||||||||
| \< | Start of word | Start of word | |||||||
| \> | End of word | End of word | |||||||
| re\? | re 0 or 1 | ||||||||
| re\+ | re 1 or more | ||||||||
| l\|r | l or r | l or r | |||||||
| (?#text) | Comment, ignored | ||||||||
| (?modifiers) | Embedded modifiers | ||||||||
| (?modifiers:re) | Shy grouping + modifiers | ||||||||
| (?:re) | Shy grouping | ||||||||
| \(?:...\) | Shy grouping | ||||||||
| (?=re) | Lookahead | ||||||||
| (?!re) | Negative lookahead | ||||||||
| (?<=p) | Lookbehind | ||||||||
| (?<!o) | Negative lookbehind | ||||||||
| (?{code}) (??{code}) |
Embedded Perl | ||||||||
| (?>re) | Independent expression | ||||||||
| (?(cond)re) (?(cond)re|re) |
Condition expression | ||||||||
| (?P<name>re) | Symbolic grouping | ||||||||
| (?P=name) | Symbolic backref | ||||||||
| String | GNU grep | BRE (grep) | ERE (egrep) | GNU Emacs | Perl | Python | Tcl | ||
浙公网安备 33010602011771号