I am thinking how you can replace [^\]%
marks but not \%
marks in the sed -command of this answer.
I think look-behind is not necessary.
My current Sed command but I think Perl is a must here
cat something | sed 's#%.*</#</#'
which removes also everything after the %
sign i.e. all comments in LaTeX but not percentage values.
My unsuccessful Perl attempt
cat something | perl 's#[^\]%.*</#</#'
where I do not know how I make Perl to take the standard output of cat.
Data
------------------------------
Protocol of pre-eclampsia
------------------------------
Monitoring in 90\% cases
Antihypertensives when % this is a comment, please, remove me!
$SBP/DBP > 160/110$; slowly.
------------------------------
Desired output
------------------------------
Protocol of pre-eclampsia
------------------------------
Monitoring in 90\% cases
Antihypertensives when
$SBP/DBP > 160/110$; slowly.
------------------------------
How can you replace %
signs but not \%
?
If you can do this by Sed, please, comment.
\%%%%%%%%
? How does<
come into it? – terdon♦ May 30 '15 at 10:13\%%%%%...
is a comment so everything after second % should be removed. – Léo Léopold Hertz 준영 May 30 '15 at 10:25\%
, that's what TeX does. However, things like\\%
and\\\%
are more problematic. – lcd047 May 30 '15 at 10:25%.*<
with#<
and I wasn't sure if he wanted comments removed or true replacement of all matching characters. I still don't know why there's s<
in the code. – terdon♦ May 30 '15 at 10:27