regex - Python catch text inside {} -


i need catch text inside {} parenthesis in python

this example

{nokia}_b {lumia 640 xl}_m {lte}_o {8gb}_s 

i need catch contain of {} parenthesis example nokia , tag _* part. example in {nokia}_b need extract both nokia , b tag. tried without success regex unfortunately doesn't work multi tokens word

{\w{1,}}_(b|m|s|c|o) 

you can use combination of capture groups , findall extract needed properties

>>> import re >>> s = "{nokia}_b {lumia 640 xl}_m {lte}_o {8gb}_s" >>> matches = re.findall(r"\{([0-9a-za-z ]*)\}", s) >>> print matches ['nokia', 'lumia 640 xl', 'lte', '8gb'] 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -