Reputation: 35
I'm trying to use sed to delete patterns like "\subsection{sometext}",
so from:
Important astrophysical issues could be solved...
\subsection{ Introduction\good line}
\subsection{? apple $ fast burry }white
abc
I want:
Important astrophysical issues could be solved...
white
abc
I have tried:
sed -E -i '' 's/\\(section|subsection|subsubsection)\{([^\}]+)\}//g' test.tex
but the result is:
Important astrophysical issues could be solved...
\subsection{ Introduction\good line}
white
abc
It seems that the text including backslash fails to match. I use MacOS.
Upvotes: 1
Views: 57
Reputation: 16624
}
inside []
does not need escaping, so:
's/\\(section|subsection|subsubsection)\{([^}]+)\}//g'
simply works.
you could see the rules in re_format(7)
:
... With the exception of these and some combinations using `[' (see next paragraphs), all other special characters, including `\', lose their special significance within a bracket expression.
Upvotes: 1