I've this regex: {([^}]+)}
It successfully captures bracket contents, e.g.
hello {foo} and {bar}
.
I also want to capture groups inside that match separated by a character, e.g.
hello {foo:bar} and {hello:world}
.
The former would produce a match on {foo:bar}
with groups {foo}
and {bar}
and the latter {hello:world}
with groups {hello}
and {world}
.
I'm not fluent in regex, and I've tried this: {([^}]+)(:([^}]))?}
and {([^}]+)(\:([^}]))?}
in case the : is a special character.
Which modification do I need to make to succeed?