block "hit" but not "white"

Posting here is no longer possible, please use the forum of a filter list project, such as EasyList
Locked
mass

block "hit" but not "white"

Post by mass »

I haven't been able to accomplish this by using regexp. Any help would be greatly appreciated :D
User avatar
Adblock Plus Fan
Posts: 1255
Joined: Sat Feb 24, 2007 11:08 am

Post by Adblock Plus Fan »

Normally there's the whitelist feature for exceptions, but what you want ('white') is too short and unspecific to recommend for a whitelist.

And regexps are not recommended either, they are very slow compared to normal filters.
User avatar
rick752
Posts: 2709
Joined: Fri Jun 09, 2006 7:59 pm
Location: New York USA
Contact:

Post by rick752 »

If it is a page element that you want to hide, you can do it like this:

Code: Select all

somesite.com##div[id*="hit"] :not([id*="white"])
User avatar
rick752
Posts: 2709
Joined: Fri Jun 09, 2006 7:59 pm
Location: New York USA
Contact:

Post by rick752 »

added to above

If it is specifically images or graphics that you are trying to do this to, this is how you would hide/allow them:

Code: Select all

somesite.com##img[src*="hit"] :not([src*="white"])

.... where something in the image's address has "hit" in it .... but it will not hide something with "hit*white" in the address. So that string says to hide anything with "hit" but :NOT if it also contains "white". It acts as an element 'self-whitelisting' rule.

Remember though that this is only 'hiding' them (still downloaded) ... NOT blocking them (not downloaded). So if you just want to do it just for visual impact you can do it this way.
mrbene
Posts: 173
Joined: Tue Apr 10, 2007 10:09 pm
Location: Seattle, WA, USA
Contact:

Post by mrbene »

The regex:

Code: Select all

[^w]hit[^e]
will match "hit" and not "white", provided "hit" is bounded by additional characters - ie, it will match "/hit/" or "/hitcounter", but it won't match the text "hit" outright.
It'll also match anything that starts with the popular four letter word for fecal matter, so you may want to include "s" in the first block, or be explicit in what bounding chars you expect:

Code: Select all

[^ws]hit[^e]
[\/\.\?_=\-\&\d\!]hit
Untested examples of the top of my head.

Enjoy.
User avatar
rick752
Posts: 2709
Joined: Fri Jun 09, 2006 7:59 pm
Location: New York USA
Contact:

Post by rick752 »

Can't use:

Code: Select all

/hit
.hit
hit/
hit.
?

None of these would block "white".
mrbene
Posts: 173
Joined: Tue Apr 10, 2007 10:09 pm
Location: Seattle, WA, USA
Contact:

Post by mrbene »

rick752 wrote:Can't use:

Code: Select all

/hit
.hit
hit/
hit.
?

None of these would block "white".
Doesn't match the exercise - none of those are regex :P
User avatar
rick752
Posts: 2709
Joined: Fri Jun 09, 2006 7:59 pm
Location: New York USA
Contact:

Post by rick752 »

Oops ... I guess I didn't read the sentence in the first post close enough. I was concentrating more on the title of the post.

Never mind :(
mrbene
Posts: 173
Joined: Tue Apr 10, 2007 10:09 pm
Location: Seattle, WA, USA
Contact:

Post by mrbene »

I'd say that either interpretation is valid - the requirement of using regex is implied by the OPs statement
I haven't been able to accomplish this by using regexp.
but the actual request isn't specifically "and how would it be done using regex"...
Locked