[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18446: A bracket expression with \- not work. grep v 2.14
From: |
Paul Eggert |
Subject: |
bug#18446: A bracket expression with \- not work. grep v 2.14 |
Date: |
Wed, 10 Sep 2014 14:05:22 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 |
On 09/10/2014 08:23 AM, nezhevenko wrote:
echo 'd' | grep -E '[A\-Z]'
d
grep is working correctly here, I'm afraid. Backslash is not special
there, so '[A\-Z]' matches 'A' and all characters in the range from '\'
through 'Z'. The size of the range depends on the locale; in some
locales the range is invalid (because '\' sorts after 'Z') but in some
it's valid and may include 'd', which is what evidently happened for you.
To get the behavior you want, use the pattern '[-AZ]'