0

Discord is testing with a new AutoMod system and it accepts regex for filtering messages. I have came up with this regex which filters out URLs: ((https?:\/\/)?[^\s.]+\.[\w][^\s]+)

This works fine, but it also filters the GIF urls too. so I want to exclude a few domains (tenor.com, giphy.com, discord.com, discordapp.net, cdn.discordapp.com, clips.twitch.tv) so I came up with this: ((https?:\/\/)?\b(?:(?!tenor|giphy|discord|clips|twitch|cdn|discordapp)\w)+\b\.[\w][^\s]+) here's the test: https://regex101.com/r/1S2j7g/2

But discord doesn't support ?! or any kind of look-ahead, look-behind. Is there a way to convert this to a regex that doesn't use any look-around?

  • I think the answer is no. RE2 doesn't have lookarounds much like AutoMod and see this solution for a much simpler situation https://stackoverflow.com/questions/26771592/negative-look-ahead-in-go-regular-expressions – MonkeyZeus Nov 08 '22 at 17:54
  • Discord uses Rust flavor regex. You can see here for a possible workaround, but it gets really complicated - https://github.com/rust-lang/regex/issues/127#issuecomment-1216934151 – DenverCoder1 Nov 08 '22 at 17:59

0 Answers0