Reputation: 1736
I have a string like this 'galore#2 abounding#1 lost#3'. But I need to split this string like this ['galore', 'abounding', 'lost']. Basically the strings should be split by number. I am a newbie in Python programming, any help would be greatly appreciated.
Upvotes: 1
Views: 57
Reputation: 82765
Using Regex. re.findall
Ex:
import re
s = 'galore#2 abounding#1 lost#3'
print(re.findall(r"[a-z]+(?=\#)", s))
Output:
['galore', 'abounding', 'lost']
Upvotes: 4