Re: Regular expression for "key = value" pairs

2010-12-23 Thread Ciccio
I extracted an isolated problem from a slightly more complex situation, that's why I'm using REs. Thank you all for your help, my problem is now solved. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression for "key = value" pairs

2010-12-22 Thread Mark Wooding
André writes: > How about the following: > > >>> s = 'a=b,c=d' > >>> t = [] > >>> for u in s.split(','): > ... t.extend(u.split('=')) s = 'a = b = c, d = e' => ['a ', ' b ', ' c', ' d ', ' e'] Ugh. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression for "key = value" pairs

2010-12-22 Thread Mark Wooding
Ciccio writes: > 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). [...] > In [12]: re.findall(r'(.+)=(.+)', s) > Out[12]: [('a=b, c', 'd')] I think there are two logically separate job

Re: Regular expression for "key = value" pairs

2010-12-22 Thread Vlastimil Brom
2010/12/22 Ciccio : > 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')] > > [...] >

Re: Regular expression for "key = value" pairs

2010-12-22 Thread André
On Wednesday, December 22, 2010 12:22:22 PM UTC-4, Francesco Napolitano wrote: > 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.fin

Regular expression for "key = value" pairs

2010-12-22 Thread Ciccio
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')] In [13]: re.findall(r'(.+?)=(.+)', s) Out[13]: