JoannEcureuil
1 years ago
I had to redo my regex notification for Katarina on FFXIV because it kept going off for venue ads that had KIT KAT in the advertising. It took me a while to figure out the correct regex that matched "Kat" and "Katarina" but also excluded "KAT" from "KIT KAT."
JoannEcureuil
1 years ago
Let me tell ya, it wasn't easy figuring it out. Simply excluding KIT KAT together doesn't work because the regex is still supposed to look for Kat, so it'll still ping the KAT in KIT KAT. Instead, I had to learn how to use negative lookahead and lookback to pin down and exclude KAT within KIT KAT and only KIT KAT.
JoannEcureuil
1 years ago
Now, in the context of anywhere else (according to regex101 editor), \b(?!Kit\sKat\b)K(at|atarina)\b would work. But in Chat Alerts, it would still ping KAT in KIT KAT. Thus, I use \b(?!KIT\sKAT\b)(?<!KIT\s)K(at|atarina)\b
It pins the KAT in KIT KAT down and says "In the context of KIT KAT, don't match it." then it continues to search for Kat or Katarina.
JoannEcureuil
1 years ago
In other words, I tell regex "Look, the Kat you found in KIT KAT isn't the Kat I'm looking for." and this is how that would be written.
立即下載
JoannEcureuil
1 years ago
(I'll write a tumblr post about this later.)