[Tutor] regular expression matching a dot?

Christian Meesters meesters at uni-mainz.de
Wed Oct 19 09:45:07 CEST 2005


Hi

I've got the problem that I need to find a certain group of file names 
within a lot of different file names. Those I want to match with a 
regular expression are a bit peculiar since they all look like:
07SS.INF , 10SE.INF, 13SS.INF, 02BS.INF, 05SS.INF.
Unfortunately there are similar file names that shouldn't be matched, 
like:
01BE.INF, 02BS.INF
Any other extension than 'INF' should also be skipped. (There are names 
like 07SS.E00, wich I don't want to see matched.)
So I tried the following pattern (using re):
\d+[SS|SE]\.INF - as there should be at least one digit, the group 'SE' 
or 'SS' followed by a dot and the extension 'INF'.

Well, this doesn't work, no match. However, if I change the pattern to 
\d+[SS|SE] it somehow works and all all valid names are matched. But if 
there is a different extension than 'INF' it matches too - but it 
shouldn't. (Surrounding the dot with [] doesn't help, though I have no 
idea as for why.)
Any ideas what I could do else?

TIA
Christian

PS Hope that I described the problem well enough ...



More information about the Tutor mailing list