[issue19055] Regular expressions: * does not match as many repetitions as possible.
janzert
report at bugs.python.org
Fri Sep 20 00:52:06 CEST 2013
janzert added the comment:
The documentation on the | operator in the re module pretty explicitly covers this. http://docs.python.org/2/library/re.html
"A|B, where A and B can be arbitrary REs, creates a regular expression that will match either A or B. An arbitrary number of REs can be separated by the '|' in this way. This can be used inside groups (see below) as well. As the target string is scanned, REs separated by '|' are tried from left to right. When one pattern completely matches, that branch is accepted. This means that once A matches, B will not be tested further, even if it would produce a longer overall match. In other words, the '|' operator is never greedy."
----------
nosy: +janzert
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19055>
_______________________________________
More information about the Python-bugs-list
mailing list