Regular Expression Question

Posting here is no longer possible, please use the forum of a filter list project, such as EasyList
Locked
SarahVulpine
Posts: 1
Joined: Wed Aug 06, 2008 11:36 am

Regular Expression Question

Post by SarahVulpine »

Greetings! I have a regular expression that I am attempting to use with ABP, though for some reason it doesn't seem to be working. I tested it in Expresso, and it appears to catch all the example links that I tossed at it. However, upon actually trying to implement it, it doesn't catch anything at all.

Here is the regular expression:

Code: Select all

http://www\.furaffinity\.net/images/c\d+_.+\.(jpg|gif)
And here is what I used to test it:

Code: Select all

http://www.furaffinity.net/images/c017_avp.jpg
http://www.furaffinity.net/images/c0_fa-fau2.jpg
http://www.furaffinity.net/images/c19_furprint.gif
http://www.furaffinity.net/images/c020_bottom.gif
http://www.furaffinity.net/images/c013_midfur.gif
http://www.furaffinity.net/images/c04_furbuy.gif
http://www.furaffinity.net/images/c012_sublevel3.gif
The ads in their native state can be seen at Furaffinity.net on the right-hand side, and should be work-safe, though I would advise playing it safe if there is any doubt. I am aware that there is a rotation of other ads that doesn't match the regular expression above, though this one is what I am primarily trying to fix.

Any help with fixing this regular expression would be greatly appreciated.

~Sarah
smk
Posts: 100
Joined: Mon Jul 14, 2008 6:54 am

Re:

Post by smk »

The regular expression, for dashes, must be preceded by a '\', to distinguish it from some regex syntax
Also, every one must be surrounded by /*/,
like, the one you're using should be:
/http:\/\/www.furaffinity.net\/images\/c\d+\_[^]+\.(jpg|gif)/
(I've fixed some other errors as well)
All regular expressions, in the filter list should have an exclamation mark next to it, and if the expression is kind'a wrong, it'll tell you

check out filterset G if you like, it's got loads of regular expressions :P

[edit]
I just checked out the site, maybe the following element hiding might be better, as the ad addresses are quite random, and the filter won't block too much:
#furaffinity.net/*(id*=-adblock)

hope this helps :)
User avatar
Adblock Plus Fan
Posts: 1255
Joined: Sat Feb 24, 2007 11:08 am

Re: Regular Expression Question

Post by Adblock Plus Fan »

I would advice against using regexps as the normal filters are optimised and (practically speaking) works thousands of times faster.

Why don't you try these instead:

Code: Select all

http://www.furaffinity.net/images/c*avp.jpg
http://www.furaffinity.net/images/c*fau*.jpg
http://www.furaffinity.net/images/c*furprint.gif
http://www.furaffinity.net/images/c*bottom.gif
http://www.furaffinity.net/images/c*midfur.gif
http://www.furaffinity.net/images/c*furbuy.gif
http://www.furaffinity.net/images/c*sublevel*.gif
regexps are slower, troublesome to create (in your case), and troublesome to edit and maintain (if you had problems creating them to begin with).


Otherwise smk's advice with element hiding is also a good idea.
smk wrote:#furaffinity.net/*(id*=-adblock)
Instead of that one, these two will cause less false positives:

Code: Select all

furaffinity.net##DIV#sidebar-loves-adblock > CENTER > A[target="_blank"][href^="http://"]

Code: Select all

furaffinity.net##*#sidebar-loves-adblock > A[href^="http://"]
And they work with Adblock Plus :P
Locked