regex (?!..) problem

Wolfgang Rohdewald wolfgang at rohdewald.de
Mon Oct 5 02:17:54 EDT 2009


On Monday 05 October 2009, Carl Banks wrote:
> What you're not realizing is that if a regexp search comes to a
>  dead end, it won't simply return "no match".  Instead it'll throw
>  away part of the match, and backtrack to a previously-matched
>  variable-length subexpression, such as ".*?", and try again with a
>  different length.

well, that explains it. This is contrary to what the documentation
says, though. Should I fill a bug report?
http://docs.python.org/library/re.html

Now back to my original problem: Would you have any idea how
to solve it?

count() is no solution in my case, I need re.search to either
return None or a match.

-- 
Wolfgang



More information about the Python-list mailing list