bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed version 3.02


From: Uwe Steinfeld
Subject: Re: sed version 3.02
Date: Wed, 4 Sep 2002 15:11:46 +0200

Hello Uwe,

Tuesday, September 3, 2002, 6:23:12 PM, you wrote:

UFM> The command
UFM> echo '00' | sed -e 's/^0*\([0-9]\)/\1/'
UFM> returns
UFM> 00
UFM> while it should return
UFM> 0
UFM> I am saying it should return 0 because that's what's returned by the
UFM> SunOS version of sed, and also what isreturned by the equivalent perl
UFM> command. Note that
UFM> echo '00' | sed -e 's/^0*\(0\)/\1/'
UFM> does in fact return
UFM> 0

I think the reason is that the regex version included in sed 3.02 does
a "greedy matching" to speak in terms of Perl. It eats all the 0's for
"0*" and then nothing is left to match [0-9]. So the match fails and
the input string is returned unchanged. Cygwin and Linux (SuSE 7.3)
give me the same result.

Solution: rebuild sed with a newer regex library. I used the version
the comes with the new GNU coreutils package and it works fine.

-- 
Best regards,
 Uwe





reply via email to

[Prev in Thread] Current Thread [Next in Thread]