I am working with some text that is full of stuff between brackets [] that I don't want. Since I can delete the brackets myself, I don't need the one-liner to do that for me, but I do need a one-liner that will remove everything between them.
What about parentheses () instead of brackets?
s/\[[^\[\]]*\]//g
(i.e. use backslashes to escape the members of the character set). – Gilles 'SO- stop being evil' Jun 12 '11 at 11:58[…]
= character set.^
as the first character means to complement the set.]
would normally be mark the end of the set, but if it's the first character other than^
, it's an ordinary character — an empty set or the complement of the empty set isn't permitted. Then[
is ordinary and]
ends the set. – Gilles 'SO- stop being evil' May 17 '13 at 18:35