Relative performance of comparable regular expressions

Barak, Ron Ron.Barak at
Tue Jan 13 09:24:02 CET 2009


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 "(.+)"


More information about the Python-list mailing list