> and I want to extract the numbers 531, 2285, ...,359.
>
> One thing for sure is that these numbers are the ONLY part that is
> changing; all the other characters are always fixed.
>

I'm not sure about what you mean by "always fixed" but I guess it means that 
you have n files with a fixed start and a changing ending, and m files with 
a fixed start and a changing ending, ....

import re
filenames=['ac99_124.txt', 'ac99_344.txt', 'ac99_445.txt']
numbers=[]
for i in filenames:
    
numbers.append(int(re.compile('[^_]*_(?P<number>[^.]*).txt').match(i).group('number')))



this sets numbers to: [124, 344, 445] 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to