@H_403_6@Notation |
@H_403_6@Description |
@H_403_6@Example RE |
---|---|---|
@H_403_6@Symbols |
@H_403_6@ |
@H_403_6@ |
@H_403_6@literal |
@H_403_6@Match literal string valueliteral |
@H_403_6@foo |
@H_403_6@re1|re2 |
@H_403_6@Match regular expressionsre1 or re2 |
@H_403_6@foo|bar |
. |
Matchany character (except NEWLINE) |
b.b |
^ |
Match start of string |
^Dear |
$ |
Match end of string |
/bin/*sh$ |
* |
Match 0 or more occurrences of preceding RE |
[A-Za-z0-9]* |
+ |
Match 1 or more occurrences of preceding RE |
[a-z]+\.com |
? |
Match 0 or 1 occurrence(s) of preceding RE |
goo? |
{N} |
Match N occurrences of preceding RE |
[0-9]{3} |
{M,N} |
Match from M to N occurrences of preceding RE |
[0-9]{5,9} |
[...] |
Match any single character fromcharacter class |
[aeIoU] |
[..x-y..] |
Match any single character in therange fromx to y |
[0-9],[A-Za-z] |
[^...] |
Do not match any character from character class,including any ranges,if present |
[^aeIoU],[^A-Za-z0-9_] |
@H_403_6@(*|+|?| {})? |
@H_403_6@Apply "non-greedy" versions of above occurrence/repetition symbols (*,+,?,{}) |
@H_403_6@.*?[a-z] |
@H_403_6@(...) |
@H_403_6@Match enclosed RE and save assubgroup |
@H_403_6@([0-9]{3})?,f(oo|u)bar |
@H_403_6@Special Characters |
@H_403_6@ |
@H_403_6@ |
\d |
Match any decimal digit,same as [0-9](\D is inverse of \d: do not match any numeric digit) |
data\d+.txt |
\w |
Match any alphanumeric character,same as [A-Za-z0-9_] (\W is inverse of\w) |
[A-Za-z_]\w+ |
\s |
Match any whitespace character,same as [ \n\t\r\v\f] (\S is inverse of\s) |
of\sthe |
@H_403_6@\b |
@H_403_6@Match any word boundary (\B is inverse of \b) |
@H_403_6@\bThe\b |
\nn |
Match saved subgroup nn (see (...) above) |
price: \16 |
\c |
Match any special character c verbatim (i.e.,with out its special meaning,literal) |
\.,\\,\* |
@H_403_6@\A (\Z) |
@H_403_6@Matchstart (end) of string (also see ^ and $ above) |
@H_403_6@\ADear |
@H_403_6@REF:Core Python Programming
原文链接:https://www.f2er.com/regex/361495.html