#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = ":[^:\s]+:|<:[^:\s]+:[0-9]+>|<a:[^:\s]+:[0-9]+>"
Local $sString = "TEMPLATES" & @CRLF & _
"--------------------------------------------------------------" & @CRLF & _
":emote:" & @CRLF & _
"<:emote:189855563893571595>" & @CRLF & _
"<a:emote:18985556389571595>" & @CRLF & _
"" & @CRLF & _
"OK MESSAGE" & @CRLF & _
"--------------------------------------------------------------" & @CRLF & _
":emote:<:emote:189855563893571595><a:emote:189855563893571595>" & @CRLF & _
"" & @CRLF & _
"BAD MESSAGE" & @CRLF & _
"--------------------------------------------------------------" & @CRLF & _
":emote::asdf ::emote::: <:hey:>" & @CRLF & _
"<:a:emote:> hey" & @CRLF & _
"" & @CRLF & _
"DOES IT WORK?" & @CRLF & _
"--------------------------------------------------------------" & @CRLF & _
"In the box below (click "Substitution" at the bottom if you can't see it) is all the characters that don't match the regex and will trigger your system to delete the message."
Local $sSubst = ""
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm