2010/12/22 Ciccio <franap...@gmail.com>: > Hi all, > suppose I have: > > s='a=b, c=d' > > and I want to extract sub-strings a,b,c and d from s (and in general from > any longer list of such comma separated pairs). > Some failed attempts: > > In [12]: re.findall(r'(.+)=(.+)', s) > Out[12]: [('a=b, c', 'd')] > > [...] > Thanks for your help, > francesco. > -- > http://mail.python.org/mailman/listinfo/python-list >
Hi, I am not sure, the regular expressions are best suited for this task, but if you have a predictable simple parameter list (with ho recursion, escaping commas or equal signs etc.), it might be viable; how about e.g. this pattern? >>> re.findall(r'([^=\s,]+)=([^=\s,]+)', s) [('a', 'b'), ('c', 'd')] >>> vbr -- http://mail.python.org/mailman/listinfo/python-list