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
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
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
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
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
7;,$_);
-Original Message-
From: Dusan Juhas [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 9:17 AM
To: [EMAIL PROTECTED]
Subject: an error in a simple regexp
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 obtai
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,
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
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
What's wrong and how to write a regexp cmd which will
transfer a number to digits with dots in between?
eg: 1234 -> 1.2.3.4
Thanx
Regards,
Dusan
--
To uns