How best to apply regexp for such a domain?

Everything about using Adblock Plus on Mozilla Firefox, Thunderbird and SeaMonkey
Post Reply
genma
Posts: 4
Joined: Tue Jan 31, 2017 5:31 pm

How best to apply regexp for such a domain?

Post by genma »

My case is to selectively block all images from a particular domain:

Code: Select all

https://somesite.net/somedir1/12345/somedir2
while allowing images from there:

Code: Select all

somesite.net/somedir1/1/somedir2

Code: Select all

somesite.net/somedir1/12/somedir2

Code: Select all

somesite.net/somedir1/123/somedir2

Code: Select all

somesite.net/somedir1/1234/somedir2
a number of random digits anywhere from 1-4 in length. if host filter allowed regexp it would probably look like this:

Code: Select all

||somesite.net/somedir1/\d{5}/somedir2$image
Where this '12345' directory is another series of random digits, but as I understand it, domain filtering does not work this way. How can I make an element rule for that?
Last edited by genma on Tue Jan 31, 2017 6:34 pm, edited 1 time in total.
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: How best to apply regexp for such a domain?

Post by mapx »

you could use

Code: Select all

/somesite\.net/somedir1/[0-9]{5}/somedir2/$image
if does not work as expected provide your real example
genma
Posts: 4
Joined: Tue Jan 31, 2017 5:31 pm

Re: How best to apply regexp for such a domain?

Post by genma »

custom filters -> ad blocking rules, this is the exact string I'm using:

Code: Select all

/static-cdn\.jtvnw\.net/emoticons/v1/[0-9]{5}/1\.0$image
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: How best to apply regexp for such a domain?

Post by mapx »

provide complete info
static-cdn.jtvnw.net/emoticons/v1 ==> does not exist
genma
Posts: 4
Joined: Tue Jan 31, 2017 5:31 pm

Re: How best to apply regexp for such a domain?

Post by genma »

example of an image I want to block:

https://static-cdn.jtvnw.net/emoticons/v1/74353/1.0

and an image I want to keep:

https://static-cdn.jtvnw.net/emoticons/v1/25/1.0
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: How best to apply regexp for such a domain?

Post by mapx »

correct filter (you forgot the final "/" )

Code: Select all

/static-cdn\.jtvnw\.net/emoticons/v1/[0-9]{5}/1\.0/$image
test it on this page (this is a real example, a page where you are using those images):
http://axistrivia.altervista.org/list/123/f1/index.html

this request is blocked
https://static-cdn.jtvnw.net/emoticons/v1/74353/1.0

this 1 is unblocked
https://static-cdn.jtvnw.net/emoticons/v1/25/1.0
genma
Posts: 4
Joined: Tue Jan 31, 2017 5:31 pm

Re: How best to apply regexp for such a domain?

Post by genma »

Thank you, this is working as expected. Never would have suspected that final slash
Post Reply