Monday, 15 March 2010

Parsing substring in python -



Parsing substring in python -

i parse substring specific pattern in python.

eg:

[ aa bb ] (cc) dd "string extract" "another string in next line" xx "another string"

i extract string in quotes lines begin [. don't need strings within quotes. how do in python?

not sure lines coming if each line different.

import re lines=['[ aa bb ] (cc) dd "string extract"',"another string in next line",'xx "another string"'] line in lines: if line.startswith("["): print re.findall(r'\"(.+?)\"',line) ['string extract']

python python-2.7

No comments:

Post a Comment