It is rather related to blacklists.
Pi-hole developers do maintain neither blacklists nor blacklisting regexs. They just provide the means of applying blacklists or regexs to their filtering engine.
Blacklist maintainers may prove more apt in providing support for your specific problem, as they may choose to put similar pattern matching challenges before them (or not).
Besides, it seems this topic is an extension of your previous HELP: Python Program to Generate/Suggest Wildcards from Blocklist)
I don't want to sound discouraging - but ![]()
Considering both topics, your design idea seems flawed to me.
First, your approach seems to have primarily wildcard blocking in mind. This would leverage just a fraction of what can be achieved by applying regular expressions.
Second, wildcarding a top level hierarchy entry within hierarchical groups as you want to assemble them would also block lower levels altogether. making the subdomain grouping somehow obsolete.
Third, applying unspecific wildcarding -even if used on your subdomains- will quite likely result in overblocking of resources.
Fourth, concentrating on the domain name hierarchy neglects other cross domain and domain substring naming patterns that prove way more significant for matching ad-serving domains.
In short: Wildcarding by itself is too unspecific to come up with a reliable, short list of regex patterns.
If you pursuit this to hone your programming skills just for fun, don't be bothered by my unqualified ramblings
and go ahead with it ![]()
Otherwise, you may want to shift your focus a bit away from the domain name hierarchy to cross domain or substring keyword pattern matching (e.g. as demonstrated by https://discourse.pi-hole.net/t/regex-examples/11354/8)