Reputation: 7087
If I have the following in a variable
\item () $0.25$
\item () $0.7$
\item
\item
how do I then remove the lines that matche \item
but not those that have a set of ()
?
If I do
$f =~ s|\\item.*?(?!\()||g;
then it deletes all \item
for some reason.
Upvotes: 3
Views: 78
Reputation: 385590
You are searching if there's a position after \item
that's not followed by (
. There is in all cases.
\item () $0.25$
^ ^^^^^^^^^ These positions aren't followed by "("
The .*?
should be in the (?!)
.
s{ ^ .*? \\item (?! [^(\n]* \( ) .* \n }{}mgx
Upvotes: 6