How to block a word with regex?

Let's say I wanted to block the word magnet, both in domain and subdomain.

So, magnet at DuckDuckGo should be blocked, as it has the word magnet in it, and https://www.magnetshop.com/ will be blocked as well.

I tried adding magnet as a wildcard, but it didn't work. So, how would I do it?

(of course I wouldn't block the word magnet, but other niche bad words, because someone is a little too curious in my house)

You can't.

In the first example, magnet isn't part of the domain. The domain is duckduckgo.com, no magnet in there. Pi-hole can't do anything ouside the domain, because it will never see that (not part of the query).
Use regex101: build, test, and debug regex to test your regexes.

2 Likes

so what about the second example, can anything be done about that?

1 Like

Even simpler:

magnet

being exactly equivalent to ^.*magnet.*$, however, much less work to be computed.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.