Re: sed bug

Paolo Bonzini <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
Il 14/02/2013 10:12, Slawomir Kuszczynski ha scritto:
> 
> 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

The regular expressions are different in the two cases.  You removed the
.* in the sed version.

$ echo ABC1234_1.0 | sed -r 's/^[A-Z]*([0-9]).*/\1/'
1

Paolo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.