This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: When Beginning Expression with Lookahead Assertion I get no Matches
Type: behavior Stage:
Components: Regular Expressions Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jwindle, mark.dickinson, mrabarnett
Priority: normal Keywords:

Created on 2009-08-28 21:49 by jwindle, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg92046 - (view) Author: Jonathan Windle (jwindle) Date: 2009-08-28 21:49
Example Code:
import re
re.findall(r"(?![a-z0-9])0(?![a-z0-9])", "a0a 0 0 b0b")

The above code returns an empty list. I expect to get ['0', '0'] returned.

If I remove "(?![a-z0-9])" from the beginning of the expression string 
findall returns values as expected.
msg92063 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2009-08-29 12:15
"(?![a-z0-9])" is a negative lookahead, so "(?![a-z0-9])0" is saying
that the next character shouldn't be any of [a-z0-9], yet it should
match "0". Hence, no matches.
msg92064 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-08-29 13:07
Thanks, MRAB!  Closing as invalid.
History
Date User Action Args
2022-04-11 14:56:52adminsetgithub: 51046
2009-08-29 13:07:34mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg92064

resolution: not a bug
2009-08-29 12:15:38mrabarnettsetnosy: + mrabarnett
messages: + msg92063
2009-08-28 21:49:57jwindlecreate