Filter wildcard and/or regular expression syntax

Everything about using Adblock Plus on Mozilla Firefox, Thunderbird and SeaMonkey
Post Reply
daver1320
Posts: 4
Joined: Mon Jun 30, 2014 4:44 pm

Filter wildcard and/or regular expression syntax

Post by daver1320 »

I have to say that the main "Writing Adblock Plus filters" page has left me totally confused about the wildcard and/or regular expression syntax. I'm actually familiar with using both wildcards and regular expressions in other applications but I can't find a good explanation of Adblock wildcards by Googling. Is there a proper explanation of Adblock wildcard syntax somwhere? Where?

For example: Apparently we can use "*" as a general string-matching wildcard, but is there a single-character matching wildcard? Normally wildcards include something like "?" to match a single character but that's evidently not the case here.

And regular expressions: regular expressions have a syntax that is contradictory to normal wildcards so an explicit indication is required to denote that that the expression IS a regular expression and not a wildcard expression. But what is that for Adblock filters? For example, foo* matches any string beginning with foo if it's a wildcard but matches "fo" followed by any number of "o"s (e.g. fooooooo) if it's a regular expression. How does Adblock know which type of expression is in use?

But never mind those specific issues, surely there is a page somewhere that properly explains the wildcard/regular expression syntax for Adblock. If so, please tell me where.
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Filter wildcard and/or regular expression syntax

Post by mapx »

regular exp (between slashes):

Code: Select all

/\.sharesix\.com/.*[a-zA-Z0-9]{4}/$script
normal wildcard:

Code: Select all

||ww1.vidzi.tv^*.js|$domain=vidzi.tv
/ads/ => regular filter
/ads/* => normal filter

Read the posts here:
forum/viewtopic.php?p=60384#p60384
daver1320
Posts: 4
Joined: Mon Jun 30, 2014 4:44 pm

Re: Filter wildcard and/or regular expression syntax

Post by daver1320 »

Thanks. So the forward slash denotes the regular expression and/or denotes the directory structure in the URL. Well, I guess I'll find my way through the logic by testing the filters to see if they do what I want.
daver1320
Posts: 4
Joined: Mon Jun 30, 2014 4:44 pm

Re: Filter wildcard and/or regular expression syntax

Post by daver1320 »

Actually I still don't get it. Say I wanted to block an element like so:

###u_0_3u

but I also wanted to block elements u_0_3s and u_0_3t etc, then what do I do?

###/u_0_3[a-z]/ doesn't seem to work

###/u_0_3.*/ doesn't seem to work

###u_0_3* doesn't seem to work either

So I don't know.
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Filter wildcard and/or regular expression syntax

Post by mapx »

No, you cannot use regular expressions in the normal hiding filters.

If you read again the filters page, you can use regular expressions only in the extended emulation hiding filters
en/filters#elemhide-emulation
Post Reply