It's called "allowlist" and "denylist" nowadays as it's easier to understand for non-native speakers and not racist.
I feel like there's an easier and faster way to match IP addresses than regex, e.g. the search tree apparia suggested. At least use bytes to match 😄