I have a string like {string}{string}{string}
which I'm able to parse by
import re
input_string = '{string}{string}{string}'
for match in re.finditer(r'{([^}]*)}', input_string):
print str(match.group(0)) #outputs {string}
but I also want to catch strings with an asterick following a curly bracket.
input_string = '{string}{string}*{string}{string}*'
How do I modify the regex so that both {string}
and {string}*
will be caught?
I tried doing r'{([^}]*)}|*'
but doesn't seem to be working.
Also, what if a string contains curly brackets? ex. {string{3}}
How do I make sure only the outer {} is caught and not the one's inside?