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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -