GNU bug report logs - #51560
Pattern matching not working as expected

Previous Next

Package: sed;

Reported by: Rob Dyck <rob.dyck <at> telus.net>

Date: Mon, 1 Nov 2021 22:45:02 UTC

Severity: normal

Full log


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

From: Davide Brini <dave_br <at> gmx.com>
To: bug-sed <at> gnu.org
Subject: Re: bug#51560: Pattern matching not working as expected
Date: Tue, 2 Nov 2021 11:12:18 +0100
On Mon, 01 Nov 2021 14:17:19 -0700, Rob Dyck <rob.dyck <at> telus.net> wrote:

> Extract the lines that start with Network
> This works as expected --~]$ ipcalc dead:beef::/64 | sed -n '/^Netwo*/p'
> Network:        dead:beef::/64
> So ^Netwo* finds the only line that starts with Network.

Remember that the * quantifier applies to the preceding element, so more
correctly, "^Netwo*" fins the lines starting with:

N, e, t, w, zero or more o

(you probably see where this is going already)

> My reasoning is that ^Netw shoud give the same result ( elimate o ).
> But no
> ipcalc dead:beef::/64 | sed -n '/^Netw*/p'
> Network:        dead:beef::/64
> Netmask:        ffff:ffff:ffff:ffff:: = 64
>
> Netmask get pulled in.

Because "^Netw*" finds lines staring with:

N, e, t, zero or more w

So sed is correct.

--
D.




This bug report was last modified 3 years and 227 days ago.

Previous Next


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