Regex can be a real pain to get your head around and/or parse visually.

I’m going to use this post to gather regex patterns/expressions that may prove useful for those of you in visual effects.

# This expression breaks a path down in to 4 named groups; the path, the file basename, frame-padding and extension


# Here’s how you might roll this out in your python script. Here I’m populating a dictionary with the path components.

pathparts = {}
regex_expr = r'^(?P<PATH>.*\\)(?P<BASENAME>[^\.]*)(?:\.)?(?P<PADDING>.*)\.(?P<EXT>.*)'
regex_groups =, path) # .group('EXT')
pathparts['dir'] ='PATH')
pathparts['filename'] ='BASENAME')
pathparts['padding'] ='PADDING')
pathparts['extension'] ='EXT')

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Skip to toolbar