regulars expressions ?

scott scott at alussinan.org
Tue Jun 28 13:45:31 EDT 2005


hi people !

<newbie>
i got some trouble with regular expressions
i need to split a string like this on the ',' character :

mystring = ""\test1, test2\", test, 42"

i wanna get something (a list) like this (3 elements) :
"test1, test2"
test
42

but the only thing i get is a list like this (4 elements) :
"test1"
"test2"
test
42

each element is separated by ',' but 1st element which is delimited by 
'"' may contain ',' character inside.

so the regular expression i need is something like :
split each element using ',' delimiter but if ',' delimiter is included 
between '"' please do not split
</newbie>

1st question is : does someone has understood the question ?
2nd question is : does someone has an answer ?

thanks people

scott



More information about the Python-list mailing list