I'm looking for a Regex that matches all addresses of a specific domain "domain.tld", except with a specific local part "fritzbox" (as an example). Unfortunately, the Sieve engine of the mail server I'm using does not support any lookarounds.
I've been here and elsewhere for hours and days, but still can't find the solution. Although there is quite a helpful example such as…
^(([^f].{2}|.[^o].|.{2}[^o]).*|.{0,2})$
…which works for any string starting with "foo", I wasn't able to adapt it to the string "fritzbox", followed by the domain "domain.tld". I'm simply not sure what these tokens "{2}" and "{0,2}" are doing exactly (must have to do with the number of characters of the string to be tested?) and why they are needed (also because the logic of this example is not being explained in the thread above).
As a sort of blind guessing, I tried…
^(([^f].{7}|.[^r].|.[^i].|.[^t].|.[^z].|.[^b].|.[^o].|.{7}[^x]).*|.{0,7})@domain\.tld$
…but that doesn't work.
I do of course know that I can do something like…
if allof (address :domain :matches "from" "domain.tld", not address :localpart :is "from" "fritzbox")
{
do something;
}
…in Sieve without Regex, but this needs to be an extra Sieve rule for this specific purpose then. I'd rather would like to be able to combine it with a bunch of other "anyof" conditions, that's why I would prefer a Regex that I can include in the same rule that contains all other conditions.
Any idea (with explanation)…?
You need to alternate between all possible options:
.{0,7}
.{9,}
f
on the first positon OR don't have an r
on the second OR don't have an i
on the third position...^(.{0,7}|[^f].{7}|.[^r].{6}|..[^i].{5}|...[^t].{4}|.{4}[^z]...|.{5}[^b]..|.{6}[^o].|.{7}[^x]|.{9,})@domain\.tld$
Here is the demo at regex101 (I used either dots or {n}
quantifier to reduce the pattern length)