Christian Meesters wrote: > 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'.
Use parentheses () for grouping. Brackets [] define a group of characters. Your re says to match \d+ one or more digits [SS|SE] exactly one of the characters S, |, E \.INF literal .INF Since there are TWO characters S or E, nothing matches. Change the [] to () and it works. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor