Regex blocking does not work correctly

Hi, I am currently having a problem with a RegEx entry in my blacklist. When my regex pattern matches the domain name, it's not being blocked.

Here is my regex pattern:

r.+?---.*?-.*?(?<!-cune)\.googlevideo\.com

This pattern should block domains like:

 r3---sn-4g5e6nes.googlevideo.com
 r3---sn-4g5e6nez.googlevideo.com
 r3---sn-4g5edne6.googlevideo.com
 r3---sn-5hnednlk.googlevideo.com
 r4---sn-4g57kn6l.googlevideo.com

And shouldn't block domains like:

r1---sn-cxoxnug5-cune.googlevideo.com
r3---sn-cxoxnug5-cune.googlevideo.com

Expected Behaviour:

DNS domains that match the RegEx rule in blacklist should be blocked.

Actual Behaviour:

They're being forwarded instead of blocked.

Debug Token:

i1cr6mbuts

Thank you.

When you run your regex pattern through Regex 101 (https://regex101.com), it shows a full match for every domain you have listed.

I don't think the regex you have written is correct for the patterns you wish to block and not block.

Also note that not every regex that passes Regex 101 checks will work with Pi-Hole properly, since Pi-Hole uses a specific set of regex rules (POSIX ERE). So, after you get your regex squared away on Regex 101, you will want to enable regex debug mode per the link below. This will trigger an entry in /var/log/pihole-FTL.log the first time each regex filter blocks a domain. You can use dig commands and see if your regex works with Pi-Hole.

1 Like

Ooops, there was a typo in the regex pattern, it should be r.+?---.*?-.*?(?<!-cune)\.googlevideo\.com. There is an error with the regex expression I wrote: ERROR compiling regex on line 2: Invalid preceding regular expression (13). How could I fix it? Im not familiar with POSIX ERE unfortunetly.

What is the output of:

cat /etc/pihole/regex.list

Currently I do not have acces to the server, however the line 2 of regex.list is the regex expression I talked about: r.+?---.*?-.*?(?<!-crune)\.googlevideo\.com

Something about that regex does not agree with Pi-Hole. The developers have more expertise in this area, so perhaps they will see the problem.

@DL6ER , @Mcat12

Negative lookbehind, (?<!), is not supported. FTL supports POSIX extended regex. More details here: Redirecting...

1 Like