bug-sed
[Top][All Lists]
Advanced

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

bug#38725: Regexp bug


From: Assaf Gordon
Subject: bug#38725: Regexp bug
Date: Tue, 24 Dec 2019 14:34:37 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

tag 38725 notabug
close 38725
stop

Hello,

On 2019-12-24 10:30 a.m., Davide Brini wrote:
On Mon, 23 Dec 2019 23:09:28 +0100, Chewbaka Roskov <address@hidden>
wrote:

akem@akem-HP:~$ echo '112233' | sed 's/2*//'  ### DOESN'T WORK
112233

You're asking for "zero or more twos". At the beginning of the string (and
between each pair of characters) there is indeed a zero-length match for
your regexp, which sed duly replaces with nothing as you asked. Had you
replaced with something or used the /g switch to the "s" command, you'd
have seen it. For example:

$ echo '112233' | sed 's/2*//g'
1133
$ echo '112233' | sed 's/2*/XXX/'
XXX112233

Thank you Davide for the clear explanation.

I'm closing this as "not a bug", but discussion can continue
by replying to this thread.

regards,
 -assaf







reply via email to

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