Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Gawk match(...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 17 of 43 Topic 2231 of 2236
Post > Topic >>

Re: Gawk match() and numbers in scientific notation

by Ed Morton <morton@[EMAIL PROTECTED] > May 7, 2008 at 09:49 PM

On 5/7/2008 1:16 PM, schuler.steffen@[EMAIL PROTECTED]
 wrote:
> On May 7, 8:03 pm, Ed Morton <mor...@[EMAIL PROTECTED]
> wrote:
> 
>>On 5/7/2008 12:50 PM, Hermann Peifer wrote:
>>
>>
>>
>>
>>>Ed Morton wrote:
>>
>>>>On 5/6/2008 6:16 AM, Hermann Peifer wrote:
>>>
>>>>>Hi,
>>>>
>>>>>I am somehwat puzzled with match() results for numbers in scientific
>>>>>notation. See below.
>>>>
>>>>>$ cat testdata
>>>>>100
>>>>>100e-3
>>>>>100E3
>>>>
>>>>>I am wondering what kind of uppercase character is matched in record
>>>>>2:
>>>>
>>>>>$ gawk '{print $1,match($1,/[A-Z]/)}' testdata
>>>>
>>>>There may not be an uppercase character matching. [A-Z] represents the
list of
>>>>characters in between the character A and the character Z in your
locale - that
>>>>does NOT mean it has to be upper case characters. For example, your
locale might
>>>>consider characters ordered as:
>>>
>>>>       aAbBcCdDeEfF....zZ
>>>
>>>You are right: in my locale en_GB.UTF-8, [A-Z] matches all upper and
>>>lower case letters (including accented letters), except lower case a.
In
>>>return [a-z] matches all upper/lower case letters, except upper case Z.
>>
>>>>so "e" would sit between "A" and "Z". That's why you should use
character
>>>>classes instead of specific ranges, e.g.:
>>>
>>>>       gawk '{print $1,match($1,/[[:upper:]]/)}' testdata
>>>
>>>I will do so. Thanks, Hermann
>>
>>As the other part of this thread continues over at comp.unix.shell, I
came up
>>with this script which you can run to see which characters are contained
in
>>which character lists (REs actually):
>>
>>$ cat rechars.awk
>># Prints every character that matches a given RE.
>># Originally created to print all characters in a given character list.
>>#
>># usage:
>>#    LC_ALL=C awk -v re="[a-z]" -f rechars.awk
>>#    LC_ALL=en_GB awk -v re="[a-z]" -f rechars.awk
>>#    awk -v re="[[:upper:]]" -f rechars.awk
>>#
>>BEGIN{
>>    for (i=0;i<=1000;i++)
>>        chars[sprintf("%c",i)]
>>    for (c in chars)
>>        if (c ~ re)
>>            s=s c
>>    print re"="s}
>>
>>$ awk -v re="[A-Z]" -f rechars.awk
>>[A-Z]=ABCDEFGHIJKLMNOPQRSTUVWXYZ
>>
>>so you can play with that if you're curious about which characters match
in
>>specific locales...
>>
>>        Ed.
> 
> 
> Why is LC_COLLATE instead of LC_ALL in the above case not enough?

It may be enough, but LC_ALL works for this and less typing.

	Ed.




 43 Posts in Topic:
Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-06 04:16:01 
Re: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-06 13:28:06 
Re: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-07 07:11:38 
Re: Gawk match() and numbers in scientific notation
Ed Morton <morton@[EMA  2008-05-07 09:18:57 
Re: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-07 19:50:11 
Re: Gawk match() and numbers in scientific notation
Ed Morton <morton@[EMA  2008-05-07 13:03:32 
Re: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-07 20:39:44 
Re: Gawk match() and numbers in scientific notation
Ed Morton <morton@[EMA  2008-05-07 21:48:37 
Re: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-08 19:21:58 
Re: Gawk match() and numbers in scientific notation
Janis <janis_papanagno  2008-05-07 07:59:10 
Re: Gawk match() and numbers in scientific notation
Ed Morton <morton@[EMA  2008-05-07 10:20:16 
Re: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-07 17:25:24 
Re: Gawk match() and numbers in scientific notation
Ed Morton <morton@[EMA  2008-05-07 10:37:01 
Re: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-07 18:04:24 
Re: Gawk match() and numbers in scientific notation
schuler.steffen@[EMAIL PR  2008-05-07 11:16:35 
Re: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-07 20:27:53 
Re: Gawk match() and numbers in scientific notation
Ed Morton <morton@[EMA  2008-05-07 21:49:51 
Re: Gawk match() and numbers in scientific notation
schuler.steffen@[EMAIL PR  2008-05-07 13:16:24 
Re: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-08 11:25:06 
[OT] collating sequences: using glibc
Steffen Schuler <schul  2008-05-09 08:51:38 
Re: [OT] collating sequences: using glibc
pk <pk@[EMAIL PROTECTE  2008-05-09 10:32:37 
Re: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-08 06:58:39 
Re: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-08 16:22:59 
OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-08 08:46:54 
Re: OT: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-08 18:11:28 
Re: OT: Gawk match() and numbers in scientific notation
Janis Papanagnou <Jani  2008-05-08 22:29:32 
Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-08 22:49:38 
Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-09 09:44:54 
Re: OT: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-09 10:24:00 
Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-08 09:45:28 
[OT] Re: OT: Gawk match() and numbers in scientific notation
Janis <janis_papanagno  2008-05-09 02:08:34 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-10 10:58:52 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-10 11:52:19 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-10 11:55:35 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-10 20:10:19 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-10 20:31:22 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Steffen Schuler <schul  2008-05-10 21:56:00 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-10 23:14:44 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Cesar Rabak <csrabak@[  2008-05-11 10:50:15 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-11 17:27:57 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
pk <pk@[EMAIL PROTECTE  2008-05-11 11:17:15 
Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
Janis Papanagnou <Jani  2008-05-10 15:07:10 
Re: OT: Gawk match() and numbers in scientific notation
Hermann Peifer <peifer  2008-05-13 03:41:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 8:52:50 CDT 2008.