Regex for domain alias rules

Hello,

I have a custom domain set up and I’ve made some alias rules that work swell. I’m trying to make one final rule that’s a catch-all but with some exclusions. I’d like my catch-almost-all rule to match anything except addresses that include the strings web, master, admin, and info.

I’m by no means a regex whiz, but I’ve arrived at a pattern that seems to accomplish what I’m looking for and is proper (PCRE2 PHP>= 7.3) regex according to regex101.com. However, the rule-creation page rejects it as invalid.

It appears that the conditional (i.e. (?(?=...)|...) ) is the problem, but I’m not sure how this can be accomplished without one, because a plain look-ahead or look-behind doesn’t seem to be able to catch the strings to be avoided while also allowing for a wildcard on both sides.

Here’s the pattern:

^(?(?=.*(web|master|info|admin).*)|[-_A-Za-z0-9]*)$

or, with actual wildcard for the conditional match:

^(?(?=.*(web|master|info|admin).*)|.*)$

I’m guessing there’s probably a much more efficient way to do this, so hoping someone can either point that out, or alternatively advise what regex flavor the alias rules use.

Thanks!

Any thoughts or advice?

Turns out the conditional wasn’t necessary after all. This seems to do the trick:

^(?!.*(web|master|info|admin).*)[-_A-Za-z0-9]+$