GNU bug report logs - #78940
REGEX wrongfully matches pattern

Previous Next

Package: sed;

Reported by: "Duchesne, Alexandre" <duchesne.alexandre.3 <at> courrier.uqam.ca>

Date: Wed, 2 Jul 2025 05:43:03 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


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

From: Davide Brini <dave_br <at> gmx.com>
To: 78940 <at> debbugs.gnu.org
Subject: Re: bug#78940: REGEX wrongfully matches pattern
Date: Wed, 2 Jul 2025 15:26:19 +0200
On Tue, 1 Jul 2025 20:26:16 +0000, "Duchesne, Alexandre"
<duchesne.alexandre.3 <at> courrier.uqam.ca> wrote:

> Hi,
> 
> I wanted to show to my classmate the comportment of a RegEX using sed to
> capture the subgroup in a pattern match.
> 
> But, when trying with sed -E, the pattern matched even though it should
> not have.
> 
> Can someone explain to me why if this comportment turns out to be normal ?
> 
> View snippet :
> 
> $ echo abc | grep -E '(...).+' -c
> 0
> $ echo abc | sed -E 's/(...).+/\1/'
> abc

This is all expected behavior. Your regexp does not match, no sostitution
is performed, and sed prints the input line unchanged, which is the default
behavior (disable with sed -n).

-- 
D.




This bug report was last modified 49 days ago.

Previous Next


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