bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15410: [:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:al


From: Eric Blake
Subject: bug#15410: [:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:alpha:] OR [:digit:]
Date: Wed, 18 Sep 2013 12:39:13 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8

On 09/18/2013 12:31 PM, Eric Blake wrote:

>> [:alnum:] is defined as
>>
>> Alphanumeric characters: ‘[:alpha:]’ *and* ‘[:digit:]’; in the ‘C’ locale
>> and ASCII character encoding, this is the same as ‘[0-9A-Za-z]’.
> 
> This sense of "and" correctly means the combination, where characters
> from either class satisfy the regex.  Writing '[[:alnum:]]' is the same
> as writing '[[:alpha:][:digit:]]'
> 

> 
> Given that the problem is in your lack of shell quoting, and not in
> grep, I'm closing this as not a bug.  However, feel free to respond if
> you have more comments.
> 

Re-reading what I just wrote, I think I'd better add more, because it
may not just be a problem with shell globbing, but also a
misunderstanding on your part:

>> 
>> ### if [:alnum] functions as ‘[:alpha:]’ *AND* ‘[:digit:]’, it should show
>> x1y1z123 only

In your sample, you specified a regex that matches exactly one byte.  It
matches all three lines, because "a" (in the "adc" line) fits the alnum
category, "x" (in the "x1y1z123" line) fits the alnum category, and "4"
(in the "456" line) fits the alnum category.  Again, it is NOT a regex
that specifies a multi-byte match, where the match has to include at
least one alpha byte and one digit byte, but a regex that specifies a
range of possible matching bytes, and the range includes both alpha and
digit bytes, but only one byte matches.

In just the same way, you can say that the regex "[ab]" matches both "a"
and "b"; or you can state that you will have a match if either "a" or
"b" is encountered; but it's all a matter of wording for which
conjunction feels most natural for the context you are using for
describing the matching.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]