December 29th, 2009, 07:24 PM
Problem with regex
Can someone help me figure out why this regex isn't working?
It is supposed to return a match of '.F123.S123' but it keeps erroring out. the 1,5 is required though as someones the numbers are between 1-5, the strings are also significantly long hence the F and S matches.
Odd thing is this works fine with the online regex tester:
Just not in python.
December 29th, 2009, 07:56 PM
1. What error?
2. Your expression doesn't account for the . between the F123 and the S123.
December 29th, 2009, 08:03 PM
I think I figured it out:
The error was "sre_constants.error: multiple repeat" so did a ton of Googling and eventually rewrote the regex, I learned a lot about it today!
December 29th, 2009, 08:49 PM
is valid in a bunch of languages: apparently Python isn't one of them.
(I actually wondered about that, but I figured Python was developed enough to support that kind of greedyness.)
December 29th, 2009, 09:29 PM
indeed, took me a while of debugging to figure out the greed + was the problem