Re: Question: Optional Regular Expression Grouping

2011-10-10 Thread galyle
On Oct 10, 4:59 pm, Vlastimil Brom wrote: > 2011/10/10 galyle : > > > > > > > > > > > HI, I've looked through this forum, but I haven't been able to find a > > resolution to the problem I'm having (maybe I didn't look hard enough > > -- I have to believe this has come up before).  The problem is t

Re: Question: Optional Regular Expression Grouping

2011-10-10 Thread Ian Kelly
On Mon, Oct 10, 2011 at 4:49 PM, MRAB wrote: > Instead of "\S" I'd recommend using "[^\]]", or using a lazy repetition > "\S+?". Preferably the former. The core problem is that the regex matches ambiguously on the problem string. Lazy repetition doesn't remove that ambiguity; it merely attempts

Re: Question: Optional Regular Expression Grouping

2011-10-10 Thread Vlastimil Brom
2011/10/10 galyle : > HI, I've looked through this forum, but I haven't been able to find a > resolution to the problem I'm having (maybe I didn't look hard enough > -- I have to believe this has come up before).  The problem is this: > I have a file which has 0, 2, or 3 groups that I'd like to rec

Re: Question: Optional Regular Expression Grouping

2011-10-10 Thread MRAB
On 10/10/2011 22:57, galyle wrote: HI, I've looked through this forum, but I haven't been able to find a resolution to the problem I'm having (maybe I didn't look hard enough -- I have to believe this has come up before). The problem is this: I have a file which has 0, 2, or 3 groups that I'd li

Question: Optional Regular Expression Grouping

2011-10-10 Thread galyle
HI, I've looked through this forum, but I haven't been able to find a resolution to the problem I'm having (maybe I didn't look hard enough -- I have to believe this has come up before). The problem is this: I have a file which has 0, 2, or 3 groups that I'd like to record; however, in the case of

Re: Regular Expression Grouping

2007-08-12 Thread Paul McGuire
On Aug 12, 12:21 pm, [EMAIL PROTECTED] wrote: > > I cannot understand why 'c' constitutes a group here without being > surrounded by "(" ,")" ? > > >>>import re > >>> m = re.match("([abc])+", "abc") > >>> m.groups() > > ('c',) > It sounds from the other replies that this is just the way re's work

Re: Regular Expression Grouping

2007-08-12 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Fairly new to this regex thing, so this might be very juvenile but > important. > > I cannot understand and why 'c' constitutes a group here without being > surrounded by "(" ,")" ? > > >>>import re > >>> m = re.match("([abc])+", "abc")

Re: Regular Expression Grouping

2007-08-12 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Fairly new to this regex thing, so this might be very juvenile but > important. > > I cannot understand and why 'c' constitutes a group here without being > surrounded by "(" ,")" ? > import re m = re.match("([abc])+", "abc") m.groups() > ('c',) > > Grat

Re: Regular Expression Grouping

2007-08-12 Thread linnewbie
On Aug 12, 1:31 pm, Fabio Z Tessitore <[EMAIL PROTECTED]> wrote: > Il Sun, 12 Aug 2007 17:21:02 +, linnewbie ha scritto: > > > Fairly new to this regex thing, so this might be very juvenile but > > important. > > > I cannot understand and why 'c' constitutes a group here without being > > surro

Re: Regular Expression Grouping

2007-08-12 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > Fairly new to this regex thing, so this might be very juvenile but > important. > > I cannot understand and why 'c' constitutes a group here without being > surrounded by "(" ,")" ? > import re m = re.match("([abc])+", "abc") m.groups() > ('c',) > > Grat

Re: Regular Expression Grouping

2007-08-12 Thread Fabio Z Tessitore
Il Sun, 12 Aug 2007 17:21:02 +, linnewbie ha scritto: > Fairly new to this regex thing, so this might be very juvenile but > important. > > I cannot understand and why 'c' constitutes a group here without being > surrounded by "(" ,")" ? > import re m = re.match("([abc])+", "abc") >

Regular Expression Grouping

2007-08-12 Thread linnewbie
Fairly new to this regex thing, so this might be very juvenile but important. I cannot understand and why 'c' constitutes a group here without being surrounded by "(" ,")" ? >>>import re >>> m = re.match("([abc])+", "abc") >>> m.groups() ('c',) Grateful for any clarity. -- http://mail.python.o