Mixing regular expression and DIV

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

Mixing regular expression and DIV

Post by Amy »

Hi folks,

I am looking how to filter a full <div> bloc when its header does not contain an id="xxxx" but contains a specific class.
in example :
<div id="tralala" class="Class1 Class2"> .....</div> must not be filtered, while
<div class="Class1 Class2"> ...</div> must be.

I tested so many syntaxes that I am completely out of mind !

Does anyone can tell me if making a such filter is even possible ?
and how ....

Thank you very much for any help.
Amy
Dr. Evil
Posts: 194
Joined: Fri Sep 08, 2006 3:51 pm

Re: Mixing regular expression and DIV

Post by Dr. Evil »

This should do the trick:

Code: Select all

example.com##div.Class1.Class2:not(#tralala)
Amy

Re: Mixing regular expression and DIV

Post by Amy »

Dr. Evil wrote:This should do the trick:

Code: Select all

example.com##div.Class1.Class2:not(#tralala)
Indeed ! Is there a place where these tricks are detaillled ? I searched through all the docs pages without find them.

In my case "tralala" is a variable number (from "p1" to "p99999"), I serched to use a regular expression, but it do not works.
I tried: example.com##div.Class1.Class2:not(#/p\d+/) and many syntax variants, without success (no matches, nothing removed).
Can a regular expression be included like that ?

Thank you
Amy
Dr. Evil
Posts: 194
Joined: Fri Sep 08, 2006 3:51 pm

Re: Mixing regular expression and DIV

Post by Dr. Evil »

Element Hiding Rules are really just CSS Selectors. A reference of all the selectors supported by Firefox can be found here: https://developer.mozilla.org/en/css_re ... electors_2

There's no selector that matches an attribute (like ID) with a regular expression, so the only way to hide the element you're concerned with would be with the "starts with" attribute selector:

Code: Select all

example.com##div.Class1.Class2:not([id^="p"])
Or, in case the page has some ids starting with "p", you'll have to use this rule:

Code: Select all

example.com##div.Class1.Class2:not([id^="p1"]):not([id^="p2"]):not([id^="p3"]):not([id^="p4"]):not([id^="p5"]):not([id^="p6"]):not([id^="p7"]):not([id^="p8"]):not([id^="p9"])
Amy

Post by Amy »

Hi,

Thank you very much, Dr.Evil, it is exactelly what I was looking for.

The second syntax is not required, because the two nested class is restrictive enough.

And thank you also for the link to the CSS reference page, it contains a lot of valuable infos !

Amy
Locked