emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#15410: closed ([:alnum:] is not [:alpha:] AND [:di


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#15410: closed ([:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:alpha:] OR [:digit:])
Date: Wed, 18 Sep 2013 18:32:03 +0000

Your message dated Wed, 18 Sep 2013 12:31:11 -0600
with message-id <address@hidden>
and subject line Re: bug#15410: [:alnum:] is not [:alpha:] AND [:digit:]... 
[:alnum:] is [:alpha:] OR [:digit:]
has caused the debbugs.gnu.org bug report #15410,
regarding [:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:alpha:] OR 
[:digit:]
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
15410: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15410
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:alpha:] OR [:digit:] Date: Wed, 18 Sep 2013 12:07:00 -0400

[: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]’. 

 

AND = need to satisfy BOTH alpha and digit

OR = need to satisfy EITHER alpha or digit

 

 

It looks like [:alpha:]AND [:digit:]’ functions as ‘[:alpha:]OR [:digit:]’, See example

 

 

Example:

# cat /tmp/c

adc

x1y1z123

456

 

# grep [[:alpha:]] /tmp/c

adc

x1y1z123

 

# grep [[:digit:]] /tmp/c

x1y1z123

456

 

# grep [[:alnum:]] /tmp/c

adc

x1y1z123

456

 

 

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


--- End Message ---
--- Begin Message --- Subject: Re: bug#15410: [:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:alpha:] OR [:digit:] Date: Wed, 18 Sep 2013 12:31:11 -0600 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8
tag 15410 notabug
thanks

On 09/18/2013 10:07 AM, Nick Aganan 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:]]'


> Example:
> 
> # cat /tmp/c
> 
> adc
> 
> x1y1z123
> 
> 456

[Your mailer is rather unconventional, and sticks lots of useless
whitespace into your content]

> 
> 
> 
> # grep [[:alpha:]] /tmp/c
> 
> adc
> 
> x1y1z123

Whoops - you didn't quote your shell argument.  I suspect you have some
single-character file names in your current directory (further bolstered
by the fact that you named your file /tmp/c, although it is not obvious
whether your current working directory is /tmp or elsewhere).
Therefore, you are falling victim to shell globbing.

Remember, if a file named 'a' exists in the current directory, then
unquoted [] expressions perform globs that might be replaced by that
file name:

$ touch a
$ echo '[[:alpha:]]' [[:alpha:]]
[[:alpha:]] a

You are NOT grepping for the char class "[[:alpha:]]", but for the
entirely different regex that matches the unfortunate file name
expansion of your glob.  Use shell quotes properly, and you will then
see the desired answers.  Or prepend 'echo' to your grep command to see
what arguments were actually being handed to grep.

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.

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

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

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