GNU bug report logs - #25750
[sed] Matching square brackets

Previous Next

Package: sed;

Reported by: 林自均 <johnlinp <at> gmail.com>

Date: Thu, 16 Feb 2017 07:16:02 UTC

Severity: normal

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: 林自均 <johnlinp <at> gmail.com>
To: 25750 <at> debbugs.gnu.org, jim <at> meyering.net, agn <at> gnu.org
Subject: bug#25750: [sed] Matching square brackets
Date: Thu, 16 Feb 2017 05:11:18 +0000
[Message part 1 (text/plain, inline)]
Hi sed maintainers,

I want to remove the square brackets in a string:

$ echo '[1,2,3]' | sed 's/\[//g' | sed 's/\]//g'
1,2,3

And it works.

However, when I want to do it in a single sed, it does not work:

$ echo '[1,2,3]' | sed 's/[\[\]]//g'
[1,2,3]

I can manage to make it work by a weird regexp:

$ echo '[1,2,3]' | sed 's/[]\[]//g'
1,2,3

Is that a bug? If it is, I would like to spend some time to fix it.

Thanks for reading this email.

Best,
John Lin
​
[Message part 2 (text/html, inline)]

This bug report was last modified 8 years and 54 days ago.

Previous Next


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