bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33418: Convert from literal string to ERE?


From: Paul Jackson
Subject: bug#33418: Convert from literal string to ERE?
Date: Sun, 18 Nov 2018 04:44:16 -0600

Hi Peng,

I do not know your goal to "create an ERE expression for any literal string" 
means.

But what your "sed -e 's/\([][?+{|()\]\)/\\\1/g' " does is to prefix any of the 
characters in
the set '\?+{|()[]' with a backslash ... so if that's what you want, then I 
think you have it.

I am a bit surprised that this pattern works, as the [...] class lacks a 
closing ']' character.

The following alternative is shorter, does the same thing, and I find less 
surprising:

sed -e 's/[]\\[?+{|()]/\\&/g'

-- 
                Paul Jackson
                address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]