Tuesday 15 January 2013

python - fetching values out of multiple brackets -



python - fetching values out of multiple brackets -

i have string

mod = 'ketobutyric_arp_rm(12);oxidation+%28hw%29(19)'

and want numbers in parentheses list kind of similar to:

mod_pos = ['12','19']

using split seems bit circuitous, , don't know how utilize find method on this.

any suggestions how can this?

here 1 way:

>>> import re >>> mod='ketobutyric_arp_rm(12);oxidation+%28hw%29(19)' >>> re.findall(r'\((\d+)\)', mod) ['12', '19']

python string

No comments:

Post a Comment