Regex trouble

akshat agarwal csd01412 at gmail.com
Wed Apr 1 10:02:21 EDT 2009


Hi,

I am trying to use the following snippet of code to print a regex match.

s = '01234567890123456789x012'

pat = r'(.*?x|[^a]+)*y'

mo = re.search(pat, s)
if mo is not None:
    print mo.group(0)

By adding one character before the 'x' in the input string, the time taken
to print the match doubles. This behaviour is not observed in perl. I am
curious to know about the difference the in regex implementations of perl
and python which causes this.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090401/17cdf611/attachment.html>


More information about the Python-list mailing list