Regular expression for file name

Miki Tebeka miki.tebeka at
Sun Jul 18 14:21:14 CEST 2004

Hello All,

In a configuration file there can be ID's and filename tokens.
The file names have a known suffix (.o or .mls) and I need to get a regular
expression that will catch filename but not an ID.

ID = r"[a-zA-Z\.]\w+(?![/\\])"
FILENAME = r"([a-zA-Z]:)?[\w./\\]+\.((mls)|(o))" 

However if I have the filename "Sources/kernel/" then
"Source" is interrupted as ID and "s/kernel/" is interrupted
as file name.

Any way to do better?

BTW: I'm using PLY ( for parsing.

Miki Tebeka <miki.tebeka at>
The only difference between children and adults is the price of the toys

More information about the Python-list mailing list