0 wide (surround) negative lookahead assertion (negative Forward View assertion): (?! EXP), which asserts that the expression cannot be matched before this position, so it will only match the location where the suffix exp does not exist.
0 width, indicating that it is not a character width.
Ex:
1>>>Import re2>>>['sale%s'% E.group (2) forEinch 3Re.finditer (R'(? m) ^\s+ (?! noreply) (\w+) (@\w+\.\w+)',4 " "5 [email protected]6 [email protected]7 [email protected]8 [email protected]9 " ")]Ten['[email protected]','[email protected]','[email protected]']
Wherein, R ' (? m) ^\s+ (?! noreply) (\w+) (@\w+\.\w+) '
(? m) on behalf of multiline, multi-line search.
^\s+ represents the number of spaces placed at the beginning of a sentence.
(?! Noreply) represents an expression that cannot be matched if there is a suffix noreply.
(\w+) Match mail user name
(\w+) (@\w+\.\w+) match mail domain name
Group (1) represents user name (below)
Group (2) represents the domain name
['sale%s'% E.group (1) forEinchRe.finditer (R'(? m) ^\s+ (?! noreply) (\w+) (@\w+\.\w+)', " "[email protected] [email protected] [email protected] [email prot Ected]" ")]['Salesales','Salepostmaster','Saleeng']
Thank:
http://blog.csdn.net/firetaker/article/details/5603756
http://blog.csdn.net/binjly/article/details/12152235
Python 0 wide Negative lookahead assertion (experience)