Python Parse regex
Posted
by
Nemo
on Stack Overflow
See other posts from Stack Overflow
or by Nemo
Published on 2012-06-28T21:02:21Z
Indexed on
2012/06/28
21:16 UTC
Read the original article
Hit count: 478
Let's say I have string in the form given below: myString={"name", "age", "address", "contacts", "Email"}
I need to get all the items of myString into a List using python. Here's what I did
r= re.search("myString=\{\"(.+)\", $\}", line)
if r:
items.append(r.group(1))
print(items)
Here line is the variable that holds the content of my text file.
What change do I have to make to my regex to get all the items in myString? Please kindly help me out. Thanks.
© Stack Overflow or respective owner