Re: a match question

2009-11-25 Thread Shawn H Corey
Orchid Fairy (兰花仙子) wrote: > On Wed, Nov 25, 2009 at 11:06 AM, John W. Krahn wrote: > >> $ perl -le '$_="aXXXb"; print "one word is $1 at $-[0] to $+[0]" while >> /(X*)/g;' >> one word is at 0 to 0 >> one word is XXX at 1 to 4 >> one word is at 4 to 4 >> one word is at 5 to 5 >> > > Thanks th

Re: a match question

2009-11-25 Thread C.DeRykus
On Nov 24, 7:06 pm, jwkr...@shaw.ca (John W. Krahn) wrote: > ... > > 1. before the a > > 2. between the a and b > > 3. before the b > > 4. after the b > > > The problem is that the third one should not be there. > > Yes it should.  Perhaps you are confused because pos() reports the > current positi

Re: a match question

2009-11-25 Thread Majian
Orchid Fairy (兰花仙子) wrote: > On Wed, Nov 25, 2009 at 11:06 AM, John W. Krahn wrote: > > >> $ perl -le '$_="aXXXb"; print "one word is $1 at $-[0] to $+[0]" while >> /(X*)/g;' >> one word is at 0 to 0 >> one word is XXX at 1 to 4 >> one word is at 4 to 4 >> one word is at 5 to 5 >> >> >

Re: a match question

2009-11-24 Thread 兰花仙子
On Wed, Nov 25, 2009 at 11:06 AM, John W. Krahn wrote: > > $ perl -le '$_="aXXXb"; print "one word is $1 at $-[0] to $+[0]" while > /(X*)/g;' > one word is  at 0 to 0 > one word is XXX at 1 to 4 > one word is  at 4 to 4 > one word is  at 5 to 5 > Thanks that's so smart~ But I'm still confused s

Re: a match question

2009-11-24 Thread John W. Krahn
Shawn H Corey wrote: Jim Gibson wrote: On 11/24/09 Tue Nov 24, 2009 4:42 PM, "Orchid Fairy (À¼»¨ÏÉ×Ó)" scribbled: On Wed, Nov 25, 2009 at 8:38 AM, Shawn H Corey wrote: It seems to be picking up an extra empty string after a non-zero length match. Thanks John and Shawn. Yup what let m

Re: a match question

2009-11-24 Thread John W. Krahn
Shawn H Corey wrote: Also: $ perl -le '$_="aXXXb"; @captured = $_ =~ m{ (X*) }gmsx;print "captured: <", join( ">, <",@captured), ">"' captured: <>, , <>, <> @captured = $_ =~ m{ (X*) }gmsx; Is usually written as: @captured = /X*/g; John -- The programmer is fighting against the two most

Re: a match question

2009-11-24 Thread Shawn H Corey
Jim Gibson wrote: > On 11/24/09 Tue Nov 24, 2009 4:42 PM, "Orchid Fairy (兰花仙子)" > scribbled: > >> On Wed, Nov 25, 2009 at 8:38 AM, Shawn H Corey wrote: >> >>> It seems to be picking up an extra empty string after a non-zero length >>> match. >>> >> Thanks John and Shawn. >> Yup what let me b

Re: a match question

2009-11-24 Thread Jim Gibson
On 11/24/09 Tue Nov 24, 2009 4:42 PM, "Orchid Fairy (兰花仙子)" scribbled: > On Wed, Nov 25, 2009 at 8:38 AM, Shawn H Corey wrote: > >> >> It seems to be picking up an extra empty string after a non-zero length >> match. >> > > Thanks John and Shawn. > Yup what let me be confused is that, wh

Re: a match question

2009-11-24 Thread 兰花仙子
On Wed, Nov 25, 2009 at 8:38 AM, Shawn H Corey wrote: > > It seems to be picking up an extra empty string after a non-zero length > match. > Thanks John and Shawn. Yup what let me be confused is that, why there is an additional empty string there? -- To unsubscribe, e-mail: beginners-unsubscr.

Re: a match question

2009-11-24 Thread Shawn H Corey
Orchid Fairy (兰花仙子) wrote: > Hi, > > # perl -le '$_="aXXXb"; print "one word is $1" while(/(X*)/g);' > one word is > one word is XXX > one word is > one word is > > > what are the three empty values in the output? Adding pos() (see `perldoc -f pos`) shows what is happening: $ perl -le '$_="aXX

Re: a match question

2009-11-24 Thread John W. Krahn
Orchid Fairy (À¼»¨ÏÉ×Ó) wrote: Hi, Hello, # perl -le '$_="aXXXb"; print "one word is $1" while(/(X*)/g);' one word is one word is XXX one word is one word is what are the three empty values in the output? The pattern X* can match zero characters. $ perl -le'$_="aXXXb"; print "one word is