#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)([a-zA-Z0-9-_.]*)@[a-zA-Z0-9-_.]*.gov{0,64}"
Local $sString = "john@president.gov" & @CRLF & _
"john1@president.gov" & @CRLF & _
"john-1@president.gov" & @CRLF & _
"Johnnnyboy@president.gov" & @CRLF & _
"" & @CRLF & _
"betty@vicepres.com" & @CRLF & _
"dan-4@vicepres.net" & @CRLF & _
"" & @CRLF & _
"thisisa64pluscharstringthisisa64pluscharstringthisisa64pluscharstring@thisisa64pluscharstring.com"
Local $sSubst = "$1,look i changed this"
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