Relative performance of comparable regular expressions

Barak, Ron Ron.Barak at lsi.com
Tue Jan 13 03:24:02 EST 2009


Hi,

I have a question about relative performance of comparable regular expressions.

I have large log files that start with three letters month names (non-unicode).

Which would give better performance, matching with  "^[a-zA-Z]{3}", or with "^\S{3}" ?
Also, which is better (if different at all): "\d\d" or "\d{2}" ?
Also, would matching "." be different (performance-wise) than matching the actual character, e.g. matching ":" ?
And lastly, at the end of a line, is there any performance difference between "(.+)$" and "(.+)"

Thanks,
Ron.



More information about the Python-list mailing list