I'm trying to grab any text outside of brackets with a regex.
Example string
Josie Smith [3996 COLLEGE AVENUE, SOMETOWN, MD 21003]Mugsy Dog Smith [2560 OAK ST, GLENMEADE, WI 14098]
I'm able to get the text inside the square brackets successfully with:
addrs = re.findall(r"\[(.*?)\]", example_str)
print addrs
[u'3996 COLLEGE AVENUE, SOMETOWN, MD 21003',u'2560 OAK ST, GLENMEADE, WI 14098']
but I'm having trouble getting anything outside of the square brackets. I've tried something like the following:
names = re.findall(r"(.*?)\[.*\]+", example_str)
but that only finds the first name:
print names
[u'Josie Smith ']
So far I've only seen a string containing one to two name [address]
combos, but I'm assuming there could be any number of them in a string.