I'm creating a class that renames a file using a user-specified format. This format will be a simple string whose str.format
method will be called to fill in the blanks.
It turns out that my procedure will require extracting variable names contained in braces. For example, a string may contain {user}
, which should yield user
. Of course, there will be several sets of braces in a single string, and I'll need to get the contents of each, in the order in which they appear and output them to a list.
Thus, "{foo}{bar}"
should yield ['foo', 'bar']
.
I suspect that the easiest way to do this is to use re.split
, but I know nothing about regular expressions. Can someone help me out?
Thanks in advance!