Wildcards / Regex info

Hi,

I am just a regular user who does not even understand the difference between wildcards and regex, but I did notice that the Regex / Wildcard blocking section contains some entries that do not appear to actually block anything. For example, the list contains:

(^|.)pubnub$

yet when I check the Query log there are lots of entries like

ps-161.pubnub.com

I also have an entry

(^|.)philips.com$

but I still find philips queries in the Query log. Can anyone explain?

on this site, you can test if your regex actually affects (matches) your domain.

on this site, you can check what your regex will try to accomplish.

your results:

no match

and

edit
here is the pihole tutorial
/edit

2 Likes

That should read:
(^|\.)pubnub$

Discourse omits the backward slash if you don’t type it twice.

Does not has a big effect on the outcome but without the backward slash pphilips.com will also match.

That still wouldn’t match ps-161.pubnub.com, as it (as per $) requires the hostname to end with pubnub.
I guess you probably meant to quote (^|\.)philips.com$?

Anyways, @jpgpi250’s above link to Pi-hole’s doc on regex contains all the relevant details to fix this.

Thanks a lot for the link to the tutorial. I had been looking for that! As to your first suggestion about testing my entries, I was completely stumped (“you can test if your regex actually affects (matches) your domain”): I have no idea what you mean by “matching your domain”.

However, thanks to the tutorial I was able to modify my entries so that they now read:
“pubnub” and “philips”. That seems to do a much better job.

I just forgot to add \.com in front of the $. The example was flawed and I did not notice. My bad.

Then we also omited to put the \ in front of the dot before com.

So to be exact and complete it should read: (^|\.)pubnub\.com$

RegEX is a bit more complicated the you now are thinking.

It you only put philips in there then that will also match: philipsscrewdriver.tools.com

If you put the complete domain in and push Wildcard then if will be coverted to the correct format in Pi-hole.

I realise that but the problem is that the sites I am trying to block use a variety of domain names, or so it would seem.

Can you give a few examples?

RegEX is extremly flexible but it has a learning curve. The first site mentioned by jpgpi250 is a great help to test lines.

The second site is great to simplify complex regEX to a visual overview to debug them or shorten them.

Remember as soon as you use a $ then you have write the full domain including thus \.com .

Thanks, I’ll bear that in mind. For the time being I am happy using such general blocks.

1 Like