Regex help

Please follow the below template, it will help us to help you!

Expected Behaviour:

I am trying to wilcard match a set of domain names that look like “.mkt.com”. There’s an ad company out there with a zillion domain names such as:
mkt3460.com
mkt2356.com
etc.

I’d like to block them. I’ve entered a regex blacklist as follows:

(^|\.)mkt\d+\.com$

When I test this regex with an online regex tester, it works as expected.

Actual Behaviour:

pihole doesn’t seem to interpret the regex the same way the online tester does and as a result, the domain names don’t get matched.

Any help would be appreciated.

Thank you,
-Mike

(^|\.)mkt[0-9]+\.com$

Pi-Hole uses a specific variety of regex (POSIX ERE) and some of the regex that pass the tests at regex101.com do not work in Pi-Hole, although they will compile.

For testing purposes, you can enable REGEX debug mode and any regex that are triggered with a domain request will be logged in /var/log/pihole-FTL.log

https://docs.pi-hole.net/ftldns/configfile/

Thank you! That was perfect!

Don’t forget to have a look at the Pi-hole docs jfb referred to.