regex - Extract informations from a string in Python? -
i have string , extract information inside it.
for example have this:
'won 3 oscars. 80 wins & 121 nominations.'
and split in order list this:
['3 oscars', '80 wins', '121 nominations']
how do in python?
thanks
a number followed space, word , word boundary. should do:
import re s = 'won 3 oscars. 80 wins & 121 nominations.' p = re.compile(r'\d+\s\w+\b') print(p.findall(s)) # ['3 oscars', '80 wins', '121 nominations']
Comments
Post a Comment