Message214257
I have the following regular expression:
In [2]: regex = re.compile("ME IS \w+", re.I)
For some reason, when using `fullmatch`, it doesn't match substrings longer than 1 for the '\w+':
In [3]: regex.fullmatch("ME IS L")
Out[3]: <_sre.SRE_Match object; span=(0, 7), match='ME IS L'>
In [4]: regex.fullmatch("me is l")
Out[4]: <_sre.SRE_Match object; span=(0, 7), match='me is l'>
In [5]: regex.fullmatch("ME IS Lucretiel")
In [6]: regex.fullmatch("me is lucretiel")
I have no idea why this is happening. Using `match` works fine:
In [7]: regex.match("ME IS L")
Out[7]: <_sre.SRE_Match object; span=(0, 7), match='ME IS L'>
In [8]: regex.match("ME IS Lucretiel")
Out[8]: <_sre.SRE_Match object; span=(0, 15), match='ME IS Lucretiel'>
In [9]: regex.match("me is lucretiel")
Out[9]: <_sre.SRE_Match object; span=(0, 15), match='me is lucretiel'>
Additionally, using `fullmatch` WITHOUT using the `re.I` flag causes it to work:
In [10]: regex = re.compile("ME IS \w+")
In [11]: regex.fullmatch("ME IS L")
Out[11]: <_sre.SRE_Match object; span=(0, 7), match='ME IS L'>
In [12]: regex.fullmatch("ME IS Lucretiel")
Out[12]: <_sre.SRE_Match object; span=(0, 15), match='ME IS Lucretiel'>
My platform is Ubuntu 12.04, using Python 3.4 installed from Felix Krull's deadsnakes PPA (https://launchpad.net/~fkrull/+archive/deadsnakes). |
|
Date |
User |
Action |
Args |
2014-03-20 18:40:40 | Lucretiel | set | recipients:
+ Lucretiel, ezio.melotti, mrabarnett |
2014-03-20 18:40:40 | Lucretiel | set | messageid: <1395340840.43.0.0546340493094.issue20998@psf.upfronthosting.co.za> |
2014-03-20 18:40:40 | Lucretiel | link | issue20998 messages |
2014-03-20 18:40:40 | Lucretiel | create | |
|