GNU bug report logs - #78677
RegEx error

Previous Next

Package: grep;

Reported by: DANIL10RUS <danilleontevkek2akk <at> gmail.com>

Date: Tue, 3 Jun 2025 04:01:03 UTC

Severity: normal

To reply to this bug, email your comments to 78677 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#78677; Package grep. (Tue, 03 Jun 2025 04:01:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to DANIL10RUS <danilleontevkek2akk <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Tue, 03 Jun 2025 04:01:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: DANIL10RUS <danilleontevkek2akk <at> gmail.com>
To: bug-grep <at> gnu.org
Subject: RegEx error
Date: Tue, 3 Jun 2025 00:25:16 +0300
[Message part 1 (text/plain, inline)]
 danil <at> archlinux ~/minecraft_server> ls purpur-*.jar | grep -i "[^a-z\-\.]"
purpur-2416.jar
danil <at> archlinux ~/minecraft_server> ls purpur-*.jar | grep -i "[^a-z\.\-]"
purpur-2416.jar


[image: изображение.png]
Hello, encountered a RegEx error. For some reason grep doesn't recognize
the “-” in \-\. but if we do \.\- it will work. Why is that?
[Message part 2 (text/html, inline)]
[изображение.png (image/png, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#78677; Package grep. (Wed, 04 Jun 2025 02:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 78677 <at> debbugs.gnu.org (full text, mbox):

From: "Dale R. Worley" <Dale.Worley <at> comcast.net>
To: DANIL10RUS <danilleontevkek2akk <at> gmail.com>
Cc: 78677 <at> debbugs.gnu.org
Subject: Re: bug#78677: RegEx error
Date: Tue, 03 Jun 2025 22:51:44 -0400
DANIL10RUS <danilleontevkek2akk <at> gmail.com> writes:
>  danil <at> archlinux ~/minecraft_server> ls purpur-*.jar | grep -i "[^a-z\-\.]"
> purpur-2416.jar
> danil <at> archlinux ~/minecraft_server> ls purpur-*.jar | grep -i "[^a-z\.\-]"
> purpur-2416.jar

> Hello, encountered a RegEx error. For some reason grep doesn't recognize
> the “-” in \-\. but if we do \.\- it will work. Why is that?

Remember that within [...], backslash is not special but - is.  So in

   [^a-z\-\.]

The class specifies (1) the range from a to z, (2) the range from / to
/, (3) the character ..  Actually, it specifies the *complement* of that
set, so grep will give you any lines that contain a character that is
not in that set.

What is it you are trying to accomplish?

Dale




This bug report was last modified 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.