bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] IGNORECASE and split()


From: Wolfgang Laun
Subject: Re: [bug-gawk] IGNORECASE and split()
Date: Fri, 20 Sep 2019 12:04:48 +0200

This little surprise is one of the (several) reasons I dislike modal
switches, i.e., single values that can turn the behaviour of a program
topsy-turvy. It's cleaner to control the behaviour of a pattern matching
using features or coding of the individual expression, e.g. a match using
/.../i (as in Perl) or the regex match using tolower(foo) ~ /.../, as
proposed in the gawk manual.

Contrary to wide-spread belief, the relation between upper case letters and
lower case letters is not bijective.
-W

On Fri, 20 Sep 2019 at 11:53, Wolfgang Laun <address@hidden> wrote:

> The value of IGNORECASE [...] does not affect field splitting when using *a
> single-character field separator.*
>
> A character string of length one is a "single character", but a regular
> expression ("/.../") containing a single character is not.
>
> -W
>
> On Fri, 20 Sep 2019 at 05:55, Peng Yu <address@hidden> wrote:
>
>> Hi,
>>
>> IGNORECASE changes the behavior of split() inconsistently. Why is it
>> so? Should it be consistent?
>>
>> awk -v IGNORECASE=1 -e 'BEGIN { n = split("abc", a, "B"); print n }' #
>> I'd expect the result be 2 here.
>> 1
>> awk -v IGNORECASE=1 -e 'BEGIN { n = split("abc", a, /B/); print n }'
>> 2
>>
>> --
>> Regards,
>> Peng
>>
>>


reply via email to

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