bug-gawk
[Top][All Lists]
Advanced

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

Re: [Question] Is this a bug?


From: arnold
Subject: Re: [Question] Is this a bug?
Date: Sun, 09 Jul 2023 01:47:53 -0600
User-agent: Heirloom mailx 12.5 7/5/10

This is exactly the right answer.

Much thanks,

Arnold

Wolfgang Laun <wolfgang.laun@gmail.com> wrote:

> grep with -P mimics Perl down to the least detail, i.e., the way Perl
> parses any input text. Thus, '\x5B' is not the same as '[' but is treated
> as '\[", an escaped bracket. Deep in the Perl 5 documentation on backslash
> in regular expressions you can find this paragraph:  *Note that a character
> expressed as one of these* [hexadhecimal] *escapes is considered a
> character without special meaning by the regex engine, and will match "as
> is". *(There is a similar paragraph on octal escapes.)
>
> (g)awk processes string literals and literal regular expressions as most
> compilers do, converting hexadecimal escapes to characters. Therefore,
> "\x5B" becomes "[" and is indistinguishable from a "[" in the input.
>
> Wolfgang
>
>
> On Fri, 7 Jul 2023 at 22:37, Sedapnya Tidur <sedapnyatidur@gmail.com> wrote:
>
> > $ gawk 'BEGIN { print match("a[", /^[^[]\x5B/) }'
> > gawk: cmd. line:1: error: Invalid regular expression: /^[^[]\/
> >
> > $ gawk -V
> > GNU Awk 5.2.2, API 3.2, (GNU MPFR 4.2.0-p9, GNU MP 6.2.1)
> >
> > $ grep -Po --color '^[^[]\x5B' <<< 'a[xxx'
> > a[
> >
>
>
> -- 
> Wolfgang Laun



reply via email to

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