Iterate over group names in a regex match?

2010-01-19 Thread Brian D
Here's a simple named group matching pattern: s = 1,2,3 p = re.compile(r(?Pone\d),(?Ptwo\d),(?Pthree\d)) m = re.match(p, s) m _sre.SRE_Match object at 0x011BE610 print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them? The result I'm looking

Re: Iterate over group names in a regex match?

2010-01-19 Thread djc
Brian D wrote: Here's a simple named group matching pattern: s = 1,2,3 p = re.compile(r(?Pone\d),(?Ptwo\d),(?Pthree\d)) m = re.match(p, s) m _sre.SRE_Match object at 0x011BE610 print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them?

Re: Iterate over group names in a regex match?

2010-01-19 Thread Alf P. Steinbach
* Brian D: Here's a simple named group matching pattern: s = 1,2,3 p = re.compile(r(?Pone\d),(?Ptwo\d),(?Pthree\d)) m = re.match(p, s) m _sre.SRE_Match object at 0x011BE610 print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them? The result

Re: Iterate over group names in a regex match?

2010-01-19 Thread Peter Otten
Brian D wrote: Here's a simple named group matching pattern: s = 1,2,3 p = re.compile(r(?Pone\d),(?Ptwo\d),(?Pthree\d)) m = re.match(p, s) m _sre.SRE_Match object at 0x011BE610 print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them?

Re: Iterate over group names in a regex match?

2010-01-19 Thread Brian D
On Jan 19, 11:28 am, Peter Otten __pete...@web.de wrote: Brian D wrote: Here's a simple named group matching pattern: s = 1,2,3 p = re.compile(r(?Pone\d),(?Ptwo\d),(?Pthree\d)) m = re.match(p, s) m _sre.SRE_Match object at 0x011BE610 print m.groups() ('1', '2', '3') Is it

Re: Iterate over group names in a regex match?

2010-01-19 Thread Brian D
On Jan 19, 11:51 am, Brian D brianden...@gmail.com wrote: On Jan 19, 11:28 am, Peter Otten __pete...@web.de wrote: Brian D wrote: Here's a simple named group matching pattern: s = 1,2,3 p = re.compile(r(?Pone\d),(?Ptwo\d),(?Pthree\d)) m = re.match(p, s) m _sre.SRE_Match

Re: Iterate over group names in a regex match?

2010-01-19 Thread MRAB
Brian D wrote: Here's a simple named group matching pattern: s = 1,2,3 p = re.compile(r(?Pone\d),(?Ptwo\d),(?Pthree\d)) m = re.match(p, s) m _sre.SRE_Match object at 0x011BE610 print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them? The