3.2.1 Regular Expression syntax (1), 3.2.1 Regular Expression
(?...)
This syntax rule is an extension of the previous syntax. It can be replaced with a specific character at the question mark position.
Example:
Print ('(?...) ')
M = re. findall (R' (a...) ', r'abcdefaghijk ')
If m:
Print (m)
The output result is as follows:
(?...)
['Abcd', 'aghi']
(? #...)
Comment out the brackets, which does not work. Skip these rules during regular expression analysis.
Example:
Print ('(? # )')
M = re. findall (U '(? # A) I ', u'ailmsux aaaadefagaiLmsuxhijk ')
If m:
Print (m)
The output result is as follows:
(? #)
['I', 'I', 'I']
(? = ...)
Forward recognition mode. When the forward character matches the character in the equal sign, it is considered to be matched, but these characters are not skipped. For example, Isaac (? = Asimov), the Isaac is recognized only when the Asimov character is reached after the Isaac character, but the Asimov won't jump over.
Example:
Import re
Print ('isaac (? = Asimov )')
M = re. findall (u'isaac (? = Asimov) ', u'abcdisaacasimovttttt ')
If m:
Print (m)
The output result is as follows:
Isaac (? = Asimov)
['Isaac ']
Cai junsheng QQ: 9073204 Shenzhen
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.