GNU bug report logs -
#38725
Regexp bug
Previous Next
Reported by: Chewbaka Roskov <akem3210 <at> gmail.com>
Date: Mon, 23 Dec 2019 22:33:02 UTC
Severity: normal
Tags: notabug
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38725 in the body.
You can then email your comments to 38725 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#38725
; Package
sed
.
(Mon, 23 Dec 2019 22:33:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Chewbaka Roskov <akem3210 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Mon, 23 Dec 2019 22:33:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello,
---------------------------------------------------------------------------
akem <at> akem-HP:~$ sed --version
sed (GNU sed) 4.4
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed <at> gnu.org>.
---------------------------------------------------------------------------
Regular expression bug:
akem <at> akem-HP:~$ echo '112233' | sed 's/2*//' ### DOESN'T WORK
112233
akem <at> akem-HP:~$ echo '112233' | sed 's/1*//' ### THIS ONE WORK
2233
akem <at> akem-HP:~$ echo 'ee112233' | sed 's/1*//' ### BUT THIS ONE DOES NOT
ee112233
---------------------------------------------------------------------------
Best regards.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-sed <at> gnu.org
:
bug#38725
; Package
sed
.
(Tue, 24 Dec 2019 17:31:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On Mon, 23 Dec 2019 23:09:28 +0100, Chewbaka Roskov <akem3210 <at> gmail.com>
wrote:
> akem <at> 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
# Blatant test case
$ echo 'abc' | sed 's/2*/XXX/g'
XXXaXXXbXXXcXXX
> akem <at> akem-HP:~$ echo '112233' | sed 's/1*//' ### THIS ONE WORK
> 2233
In this case 1* matches at the beginning of the string as before, but it's
allowed to match more than zero characters, so the "11" (the match for 1*)
is replaced with nothing.
> akem <at> akem-HP:~$ echo 'ee112233' | sed 's/1*//' ### BUT THIS ONE DOES NOT
> ee112233
Same as first case.
--
D.
Information forwarded
to
bug-sed <at> gnu.org
:
bug#38725
; Package
sed
.
(Tue, 24 Dec 2019 21:35:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 38725 <at> debbugs.gnu.org (full text, mbox):
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 <akem3210 <at> gmail.com>
> wrote:
>
>> akem <at> 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
Added tag(s) notabug.
Request was from
Assaf Gordon <assafgordon <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 24 Dec 2019 21:35:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
38725 <at> debbugs.gnu.org and Chewbaka Roskov <akem3210 <at> gmail.com>
Request was from
Assaf Gordon <assafgordon <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 24 Dec 2019 21:35:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-sed <at> gnu.org
:
bug#38725
; Package
sed
.
(Fri, 27 Dec 2019 23:19:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 38725 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thank you very much, sorry for misreporting this as a bug.
[Message part 2 (text/html, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 25 Jan 2020 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 209 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.