I have a template string like so:
'%album_artist%/%album%{ (%year%)}/{%track_number%. }%track_artist% - %title%'
I want to find all variables, that are not optional, thus not enclosed by curly braces: track_artist
, title
, album_artist
and album
but not track_number
and year
.
Currently, my expression is '(?<![{])%([A-Za-z_]+)%(?![}])'
, but that also matches year
.
What do I have to change in order to have the regex not beeing confused by additional characters around the variable name or multiple variables inside the curly braces?
I use Python's re
.
Related Questions: