Help with regex
Robert Dailey
rcdailey at gmail.com
Thu Aug 6 11:35:57 EDT 2009
Hey guys,
I'm creating a python script that is going to try to search a text
file for any text that matches my regular expression. The thing it is
looking for is:
FILEVERSION #,#,#,#
The # symbol represents any number that can be any length 1 or
greater. Example:
FILEVERSION 1,45,10082,3
The regex should only match the exact above. So far here's what I have
come up with:
re.compile( r'FILEVERSION (?:[0-9]+\,){3}[0-9]+' )
This works, but I was hoping for something a bit cleaner. I'm having
to create a special case portion of the regex for the last of the 4
numbers simply because it doesn't end with a comma like the first 3.
Is there a better, more compact, way to write this regex?
More information about the Python-list
mailing list