I'm using Python 3 and working with title strings that have a bracketed tag with a pair of names separated by a +
. Like this: [John+Alice] A title here.
I've been using the regex expression re.search('\[(.+)\]', title)
to get the tag [John+Alice]
, which is fine, but it's a problem when encountering a title with more than one bracketed tag:
[John+Alice] [Hayley + Serene] Another title.
That gives me [John+Alice] [Hayley + Serene]
, when I would prefer [John+Alice]
and [Hayley + Serene]
.
How can I modify the regex to give me all bracketed tags that have +
between [
and ]
? Thanks.