GNU bug report logs - #31816
Saved Sub String Only Saves Last

Previous Next

Package: sed;

Reported by: Mark.Ot2o <at> gmail.com

Date: Wed, 13 Jun 2018 17:54:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mark Otto <mark.ot2o <at> gmail.com>
To: 31816 <at> debbugs.gnu.org
Subject: bug#31816: Saved Sub String Only Saves Last
Date: Wed, 13 Jun 2018 13:03:16 -0400
[Message part 1 (text/plain, inline)]
If I use a saved substring it should capture the maximum number of
characters that fit the pattern, in this case  [0-9][0-9]*.

echo "I'm 2254 years old"|sed "s/^..*\([0-9][0-9]*\) /She's \1 /"
She's 4 years old"


She should be 2254 years old.

It does search correctly because without the substring it replaces all the
digits:

echo "I'm 2287 years old"|sed "s/^..*[0-9][0-9]*/She's many/"
She's many years old"


Here is my version information:

sed --version # On Windows 10
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>.
[Message part 2 (text/html, inline)]

This bug report was last modified 6 years and 333 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.