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, it doesn't match, but it won't be changed => 3 is written => 1.23 is written. > 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 Don't write a regexp: echo 1234 |perl -e 'print join ".", split //' or if you really need a regexp: echo 1234 | perl -pe 's/(\d)(?=\d)/$1./g'; Best Wishes, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]