# RegEx engine improvements

**URL:** https://discourse.pi-hole.net/t/regex-engine-improvements/34751
**Category:** General
**Tags:** regex, v5-2
**Created:** [June 22, 2020, 7:44pm UTC](https://discourse.pi-hole.net/t/regex-engine-improvements/34751 "2020-06-22T19:44:35Z")
**Posts on this page:** 1
**Showing post:** 34

<div class="post-metadata">

### Author: ![jpgpi250](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jpgpi250/32/286_2.png) [@jpgpi250](https://discourse.pi-hole.net/u/jpgpi250)
#### Post date: [July 7, 2020, 7:16am UTC](https://discourse.pi-hole.net/t/regex-engine-improvements/34751/34 "2020-07-07T07:16:23Z")

</div>

> [@DL6ER](#):
>
> We have seen requests for blocking specific query types. This seems to be the simplest realization. I do not expect extensive usage.

I assume you refer to [this](https://discourse.pi-hole.net/t/option-to-block-not-forward-all-aaaa-queries/34837) topic (blocking specific query types).

I have been thinking about this, and found a feature is missing in pihole-FTL, to turn this into a valid business case, I'll try to explain.

I'm already using the database schema, that allows duplicate entries in the domainlist table, so entering an identical whitelist/blacklist is possible. This works great if you want to block something for all clients (default group), but allow access for some clients (example used in earlier conversations: allowfacebook group)

This method **cannot be used** if a regex like **.\*; querytype=AAAA** is used, because it would result in allowing **all** AAAA queries for certain clients, when using it as a whitelist regex (whitelist always wins). In order to use the above regex, it needs to be used as a blacklist regex entry, targeting specific clients.

Now comes the dilemma. If I want to apply this regex to all but some clients (use it as a blacklist regex), I need to create a group with all the clients, except the ones I want to allow making AAAA queries. This list (can be) very large, and probably will not be effective (new clients aren't member of this group)

Most firewalls have a solution for this dilemma, simply specify the clients (IPs) you want to be unaffected by the rule, and **invert the selection**. The result is all clients (IPs) except the ones listed. It looks like this:

 ![image](https://discourse.pi-hole.net/uploads/default/original/3X/3/4/3434ee77e94a735b01eee3d17b7dce1c7be2c61d.png)

and the result is this:

 ![image](https://discourse.pi-hole.net/uploads/default/original/3X/d/9/d930b6cef3b1e545c0c0673ff118f58e259dddc4.png)

for pihole, this would mean you assign a limited number of clients (IP's) to a group, **invert the selection** , thus effectively targeting all clients, except the ones listed.

The above regex example would than target the **! AllowAAAAqueries** group, making it a lot more effective in an environment where new clients come and go on a regular bases.

**Something to consider** , while your making all these great changes to pihole-FTL?

---

_[View the full topic](https://discourse.pi-hole.net/t/regex-engine-improvements/34751)._
