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: Peng Yu
Subject: Re: [bug-gawk] IGNORECASE and split()
Date: Fri, 20 Sep 2019 06:23:00 -0500

This will work.

$ awk -v IGNORECASE=1 -e 'BEGIN { n = split("abc", a, "[B]"); print n }'
2

Is there a way to convert any string that is used as a regex into an
equivalent form that can understand IGNORECASE? Thanks.

On 9/20/19, Wolfgang Laun <address@hidden> wrote:
> 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
>>>
>>>
>


-- 
Regards,
Peng



reply via email to

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