Regex expression in Python to match text after words and between angle brackets -


given string: "group <stuffhere> user <iwantthis> ip <notimportant> address <ialsowantthis> assigned",

how extract things in brackets after 'user' , address. take above string , return

(iwantthis, ialsowantthis) 

try this, it'll match text between <>:

s = "group <stuffhere> user <iwantthis> ip <notimportant> address <ialsowantthis> assigned" ans = re.findall(r'<(.+?)>', s) 

now it's easy extract parts we're interested in:

ans[1] => 'iwantthis' ans[3] => 'ialsowantthis' 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -