bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: [gawk] RE bug??


From: Stephen Davies
Subject: Re: [gawk] RE bug??
Date: Fri, 8 Jul 2005 13:04:48 +0930
User-agent: KMail/1.5.1

G'day Bob.
Now I am even more confused.
Here is the output that I see here:

bash-3.00$ echo Silver | awk '/[[:upper:]][[:upper:][:digit:]]+/'
bash-3.00$ echo Silver | awk '/[A-Z][A-Z0-9]+/'
bash-3.00$ echo Silver | LC_COLLATE=en_US awk '/[A-Z][A-Z0-9]+/'
bash-3.00$ echo Silver | LC_COLLATE=POSIX awk '/[A-Z][A-Z0-9]+/'
bash-3.00$ awk --version
GNU Awk 3.1.4

All of the above is exactly what I would expect and believe to be 
correct. The pattern says (I believe) that I want an upper character 
followed by one or more upper or numeric characters. 
The second and subsequent characters of Silver are neither so it should 
not match - as shown above.

I do not understand how your results can be.

Cheers and thanks,
Stephen


On Fri, 8 Jul 2005 12:15 pm, Bob Proulx wrote:
> Stephen Davies wrote:
> > Stepan Kasal wrote:
> > > "Silver" and "Actinium" both match /[[:upper:][:digit:]]+/ and
> > > /[A-Z][A-Z0-9]+/
> > How do Silver and Actium match  /[A-Z][A-Z0-9]+/ ?
> > 
> > I agree that my code was the original problem rather than gawk but 
do 
> > not see how the above can match.
> 
> It can depending upon your locale setting.  For example on my system:
> 
>   echo Silver | LC_COLLATE=en_US awk '/[A-Z][A-Z0-9]+/'
>   Silver
> 
> And it affects other programs that use the RE library too.
> 
>   echo Silver | LC_COLLATE=en_US grep -E '[A-Z][A-Z0-9]+'
>   Silver
> 
> But of course with LC_COLLATE=POSIX or C then it won't.  So whether it
> does or not is actually a it depends upon your locale setting.  Using
> the character classes [:upper:] and [:digit:] as you are doing avoids
> these issues.
> 
> Bob
> 

-- 
========================================================================
This email is for the person(s) identified above, and is confidential to
the sender and the person(s).  No one else is authorised to use or
disseminate this email or its contents.

Stephen Davies Consulting                            Voice: 08-8177 1595
Adelaide, South Australia.                             Fax: 08-8177 0133
Computing & Network solutions.                       Mobile:0403 0405 83

Attachment: pgpUmZvgbhG3m.pgp
Description: signature


reply via email to

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