GNU bug report logs -
#72850
Can't match ] in [ ] regexp bug?
Previous Next
Reported by: Khoa Ton <khoa <at> puresynergy.com>
Date: Wed, 28 Aug 2024 07:01:02 UTC
Severity: normal
Tags: notabug
Done: Collin Funk <collin.funk1 <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72850 in the body.
You can then email your comments to 72850 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org:
bug#72850; Package
grep.
(Wed, 28 Aug 2024 07:01:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Khoa Ton <khoa <at> puresynergy.com>:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org.
(Wed, 28 Aug 2024 07:01:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I'm on Ubuntu:
$ uname -a
Linux nile 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
I can't seem to get grep to match lines with ] in them when using [ ] expression.
grep only matches two characters string "\]" instead:
$ echo ']' | grep -E "[\]]" # supposed to return ] but doesn't
$ echo '\]' | grep -E "[\]]" # incorrectly matches '\]' but not ']'
\]
Possible grep bug:
grep doesn't seem to correctly handle escaped "\]" inside [ ] expressions.
Thank you,
Khoa
Information forwarded
to
bug-grep <at> gnu.org:
bug#72850; Package
grep.
(Wed, 28 Aug 2024 08:34:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 72850 <at> debbugs.gnu.org (full text, mbox):
Khoa Ton <khoa <at> puresynergy.com> wrote:
> I'm on Ubuntu:
>
> $ uname -a
> Linux nile 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
>
> I can't seem to get grep to match lines with ] in them when using [ ] expression.
> grep only matches two characters string "\]" instead:
>
> $ echo ']' | grep -E "[\]]" # supposed to return ] but doesn't
> $ echo '\]' | grep -E "[\]]" # incorrectly matches '\]' but not ']'
> \]
>
> Possible grep bug:
> grep doesn't seem to correctly handle escaped "\]" inside [ ] expressions.
>
> Thank you,
> Khoa
Grep doesn't support backslash escapes inside [...] (although awk does).
The correct way to do this is to place the ] as the first character
inside the [...], like so:
$ echo ] | grep -E '[]]'
]
HTH,
Arnold
Information forwarded
to
bug-grep <at> gnu.org:
bug#72850; Package
grep.
(Thu, 29 Aug 2024 08:57:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 72850 <at> debbugs.gnu.org (full text, mbox):
On 8/28/2024 1:32 AM, arnold <at> skeeve.com wrote:
> Khoa Ton <khoa <at> puresynergy.com> wrote:
>
>> I'm on Ubuntu:
>>
>> $ uname -a
>> Linux nile 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
>>
>> I can't seem to get grep to match lines with ] in them when using [ ] expression.
>> grep only matches two characters string "\]" instead:
>>
>> $ echo ']' | grep -E "[\]]" # supposed to return ] but doesn't
>> $ echo '\]' | grep -E "[\]]" # incorrectly matches '\]' but not ']'
>> \]
>>
>> Possible grep bug:
>> grep doesn't seem to correctly handle escaped "\]" inside [ ] expressions.
>>
>> Thank you,
>> Khoa
>
> Grep doesn't support backslash escapes inside [...] (although awk does).
>
> The correct way to do this is to place the ] as the first character
> inside the [...], like so:
>
> $ echo ] | grep -E '[]]'
> ]
>
> HTH,
>
> Arnold
>
Thank you.
Khoa
Added tag(s) notabug.
Request was from
Collin Funk <collin.funk1 <at> gmail.com>
to
control <at> debbugs.gnu.org.
(Sun, 10 Aug 2025 03:32:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
72850 <at> debbugs.gnu.org and Khoa Ton <khoa <at> puresynergy.com>
Request was from
Collin Funk <collin.funk1 <at> gmail.com>
to
control <at> debbugs.gnu.org.
(Sun, 10 Aug 2025 03:32:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org.
(Sun, 07 Sep 2025 11:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 88 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.