#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?<emoji>(:)([a-zA-Z0-9_]+)(:))|(?<embed_emoji>(\[)([a-zA-Z0-9_]+)(\])\([^()]*\))"
Local $sString = ":emojisomeothertext:" & @CRLF & _
":someothertextemoji:" & @CRLF & _
":someemojiothertext:" & @CRLF & _
":emoji:" & @CRLF & _
"text with no emoji" & @CRLF & _
"text with :emoji_some_text: and no emoji" & @CRLF & _
"text with :emoji:" & @CRLF & _
"text with [ImageEmoji]" & @CRLF & _
"These image [emoji]'s were added due to vesktop making emojis into embeds like that." & @CRLF & _
"This regex isn't perfect but i doubt anyoue would post emojis like: "[this:" anyway." & @CRLF & _
"[HuTaoPeek](https://cdn.discordapp.com/emojis/844898526243586049.webp?size=512&name=HuTaoPeek)"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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