Re: Groups in regular expressions don't repeat as expected

2011-04-24 Thread John Nagle
On 4/21/2011 6:16 AM, Neil Cerutti wrote: On 2011-04-20, John Naglena...@animats.com wrote: Findall does something a bit different. It returns a list of matches of the entire pattern, not repeats of groups within the pattern. Consider a regular expression for matching domain

Re: Groups in regular expressions don't repeat as expected

2011-04-21 Thread Neil Cerutti
On 2011-04-20, John Nagle na...@animats.com wrote: Findall does something a bit different. It returns a list of matches of the entire pattern, not repeats of groups within the pattern. Consider a regular expression for matching domain names: kre =

Re: Groups in regular expressions don't repeat as expected

2011-04-21 Thread Vlastimil Brom
2011/4/20 John Nagle na...@animats.com: Here's something that surprised me about Python regular expressions. krex = re.compile(r^([a-z])+$) s = abcdef ms = krex.match(s) ms.groups() ('f',) ... If a group is contained in a part of the pattern that matched multiple times, the last match

Re: Groups in regular expressions don't repeat as expected

2011-04-21 Thread Vlastimil Brom
2011/4/20 MRAB pyt...@mrabarnett.plus.com: On 20/04/2011 20:20, John Nagle wrote: Here's something that surprised me about Python regular expressions. ... You should take a look at the regex module on PyPI. :-) -- Ah well... sorry for possibly destroying the point and the aha! effect ...

Groups in regular expressions don't repeat as expected

2011-04-20 Thread John Nagle
Here's something that surprised me about Python regular expressions. krex = re.compile(r^([a-z])+$) s = abcdef ms = krex.match(s) ms.groups() ('f',) The parentheses indicate a capturing group within the regular expression, and the + indicates that the group can appear one or more times.

Re: Groups in regular expressions don't repeat as expected

2011-04-20 Thread Neil Cerutti
On 2011-04-20, John Nagle na...@animats.com wrote: Here's something that surprised me about Python regular expressions. krex = re.compile(r^([a-z])+$) s = abcdef ms = krex.match(s) ms.groups() ('f',) The parentheses indicate a capturing group within the regular expression, and the +

Re: Groups in regular expressions don't repeat as expected

2011-04-20 Thread MRAB
On 20/04/2011 20:20, John Nagle wrote: Here's something that surprised me about Python regular expressions. krex = re.compile(r^([a-z])+$) s = abcdef ms = krex.match(s) ms.groups() ('f',) The parentheses indicate a capturing group within the regular expression, and the + indicates that

Re: Groups in regular expressions don't repeat as expected

2011-04-20 Thread John Nagle
On 4/20/2011 12:23 PM, Neil Cerutti wrote: On 2011-04-20, John Naglena...@animats.com wrote: Here's something that surprised me about Python regular expressions. krex = re.compile(r^([a-z])+$) s = abcdef ms = krex.match(s) ms.groups() ('f',) The parentheses indicate a capturing group