First off, I am new to regex. But so far I am in love with them. I am using regex to extract info from an image files name that I get from render engine. So far this regex is working decently...
_([a-z]{2,8})_?(\d{1,2})?(\.|_)(\d{3,10})\.([a-z]{2,6})$
If I use the split() method on a file name such as...
image_file_name_ao.0001.exr
I get back I nice little list I can use....
['image_file_name', 'gi', None, '.', '0001', 'exr', '']
My only concern is that it always returns an empty string last. No matter how I change or manipulate the regex it always gives me an empty string at the end of the list. I am totally comfortable with ignoring it and moving on, but my question is am I doing something wrong with my regex or is there something I can do to make it not pass that final empty string? Thank you for your time.
re.splitinstead of capturing groups, as in Katzwinkel's answer ? - By the way , why don't you capture in groups the potential undescore before(\d{1,2})?and the last dot ?