I know how to swap something with something with privoxy, e.g:

s/class="node ad"/class="node ad" style="display:none"/g

But how can I delete a line with privoxy? E.g.: If a line contains:

RANDOM STRING BEFORE<a href="/forum/100">Offtopic</a></td>RANDOM STRING AFTER

then what should I write in the user.action file to delete the line?

I'm searching for this kind of "sed" effect in Privoxy:

echo -e "asdf\nsomething2\nadf" | sed '/thing2/d;'

If I use "/Offtopic/d" in the user.filter file it doesn't works. (And yes, I have other rules in user.filter perfectly working.)


You may want to read up on regular expressions. The line you posted is a regular expression:

s/class="node ad"/class="node ad" style="display:none"/g

It means "replace every occurrence of the first string with the second one".

If you want to delete something, you can just leave the second string empty, like so:

s/class="node ad"//g

This would remove all occurrences of that string.

If you want to match a whole line, you could use:


Where ^ is a special character meaning "beginning of line", $ means "end of line", . means any character and * means zero or more repetitions of that character.

So it would match "zero or more repetitions of any character", then "some_string", and then "zero or more repetitions of any character" again (which should achieve what you want).

Here's a good introduction to regular expressions if you want to learn more.

| improve this answer | |
  • thanks for trying to help, but "s/^.*some_string.*$//g" doesnt works. it doesn't deletes the line containing the offtopic string. – LanceBaynes Mar 16 '11 at 11:09
  • 1
    That's quite possible, since different programs use different regular expression engines so there are often subtle differences in behaviour. I don't know specifically about Privoxy, so I can't help you there. But you can try replacing the s in the beginning of the expressions with an m. If you really want to understand how this works and how to debug a non-working regular expression, you aren't going to be able to avoid learning the syntax tough. You can start here: regular-expressions.info/anchors.html – Cedric Mar 16 '11 at 12:21

I don't know Privoxy but judging form the replacement statements above this one could work:

s/^.*<a href="/forum/100">Offtopic</a></td>.*$//
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.