sed bug
Slawomir Kuszczynski <[email protected]>
| Newsgroups | gmane.comp.gnu.utils.bugs |
|---|---|
| Message-ID | <CADHj4pg_42cYPTkRO44wf9aN-0Efuue7x56pUhJJwsi6g0o6aQ@mail.gmail.com> |
Hi, I found bug in sed. It is related to reverse matching, see examples below: Result of this simple sed: echo ABC1234_1.0 | sed -r 's/^[A-Z]*([0-9])/\1/' is: 1234_1.0 but should be: 1 This not happen in python2.7 and python3.2: $ python -c "import re; print(re.sub(r'^[a-zA-Z]*([0-9]).*',r'\1', 'ABC1234_1.0'))" 1 Environment details: $ sed --version GNU sed version 4.2.1 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, to the extent permitted by law. 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: <[email protected]>. Be sure to include the word ``sed'' somewhere in the ``Subject:'' field. $ uname -a Linux jaaa 3.0.0-30-generic #47-Ubuntu SMP Wed Jan 2 23:16:29 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux -- BR, Slawomir Kuszczynski