[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed bug
From: |
Paolo Bonzini |
Subject: |
Re: sed bug |
Date: |
Thu, 14 Feb 2013 13:19:44 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
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
- sed bug, Slawomir Kuszczynski, 2013/02/14
- Re: sed bug,
Paolo Bonzini <=
- Re: sed bug, Davide Brini, 2013/02/15
- Message not available