Possibly change default 'wildcard' regexp

I am fairly new to regex so apologies if this is not correct in terms of syntax.

I have noticed that (^|\.) seems to require a fair amount more steps than alternative methods. Could it be worth swapping to something along the lines of \bdoubleclick\.net$?

Two examples compared below:

Bonus:

URL: adspaces.ero-apaces.ero-advertising.com

  • (^|\.)ero-advertising\.com$ > 1 match, 91 steps
  • \bero-advertising\.com$ > 1 match, 31 steps

I know we may only be talking a few milliseconds here and there, but I am sure it will add up.

For wildcards I am personally using the contents of EasyList, EasyPrivacy and adguard simplified domains in a conf file, updated via cron job.

This suggestion was really just for those that may add the odd wildcard here or there.

This method, given \bdomain\.com$, would block my-domain.com when it should pass through unblocked.

You are quite right. I'll take another look as there were other much more efficient options too.

@Mcat12 another example:

URL: adspaces.ero-apaces.ero-advertising.com

  • (^|\.)ero-advertising\.com$ > 1 match, 91 steps
  • ^([^.\s]+\.)*ero-advertising\.com$ > 1 match, 35 steps

URL: adclick.g.doubleclick.net

  • (^|\.)doubleclick\.net$ > 1 match, 52 steps
  • ^([^.\s]+\.)*doubleclick\.net$ > 1 match, 31 steps

URL: ads.pi-hole.net

  • (^|\.)pihole\.net$ > 1 match, 27 steps
  • ^([^.\s]+\.)*pihole\.net$ > 1 match, 23 steps

Since the regex is only evaluated once, I think a more readable solution wins over a complicated but slightly faster solution.

2 Likes

Those are supported. They do not have to appear in that tutorial to be supported.

Understood :slight_smile:

It may appear to be more complex because it’s checking for a couple more things, but there’s something about including the caret (^) in a capture group (or, just not at the start of the line) that increases the steps / processing time quite significantly.

Edit: Look at the difference in steps / processing for these two:

The documentation says this:

We implement the POSIX Extended Regular Expressions similar to the one used by the UNIX egrep (or grep -E ) command.

https://docs.pi-hole.net/ftldns/regex/overview/