Re: (?=\d) [Was Re: an error in a simple regexp]

2002-07-15 Thread Jeff 'japhy' Pinyan
On Jul 15, Kevin Pfeiffer said: >Jeff 'japhy' Pinyan writes: >[...] >> Here's a working regex: >> >> s/(\d)(?=\d)/$1./g; > >[converts 1234 to 1.2.3.4] > >> The (?=\d) looks ahead for a digit, without actually consuming it. > >What does that mean? Does it say, "match a digit, but always check to

(?=\d) [Was Re: an error in a simple regexp]

2002-07-14 Thread Kevin Pfeiffer
Jeff 'japhy' Pinyan writes: [...] > Here's a working regex: > > s/(\d)(?=\d)/$1./g; [converts 1234 to 1.2.3.4] > The (?=\d) looks ahead for a digit, without actually consuming it. What does that mean? Does it say, "match a digit, but always check to see that there is still at least one remai

RE: an error in a simple regexp

2002-07-14 Thread Janek Schleicher
Jess Balint wrote at Fri, 12 Jul 2002 20:03:58 +0200: > You need '?'; > > echo 123 | perl -pe 's/(\d?)(\d)/$1.$2/g' > That doesn't really work. Look at echo 123456 | perl -pe 's/(\d?)(\d)/$1.$2/g' what prints 1.23.45.6 Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For ad

RE: an error in a simple regexp

2002-07-12 Thread Timothy Johnson
Ooh. I like that better than mine. :) -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 11:08 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: an error in a simple regexp On Jul 12, Dusan Juhas said: >I type

RE: an error in a simple regexp

2002-07-12 Thread Balint, Jess
You need '?'; echo 123 | perl -pe 's/(\d?)(\d)/$1.$2/g' [Jess] -Original Message- From: Dusan Juhas [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: an error in a simple regexp Hi, I typed this simple cmd in the bash: echo 123 |perl -pe 's

RE: an error in a simple regexp

2002-07-12 Thread Timothy Johnson
That's because after your regex has processed the first two numbers, it moves on to the next two numbers. If you inputted 1234, you would probably get back "1.23.4". If I were you, I'd try something more like this: my @numarray = split(//,$_); $_ = join('.',$_); -Original Message- Fro

Re: an error in a simple regexp

2002-07-12 Thread Janek Schleicher
Dusan Juhas wrote at Fri, 12 Jul 2002 18:16:44 +0200: > Hi, > I typed this simple cmd in the bash: > echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' > and expected ouput like > 1.2.3 > but obtained this one: > 1.23 > First your regexp finds (1)(2) what is a matching. So 1.2 is written. Then 3 is left,

Re: an error in a simple regexp

2002-07-12 Thread Jeff 'japhy' Pinyan
On Jul 12, Dusan Juhas said: >I typed this simple cmd in the bash: >echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' >and expected ouput like >1.2.3 >but obtained this one: >1.23 The reason you don't get "1.2.3" is because by the time Perl has matched "12", it can't match the "2" again. Here's a working