#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?im)^((?:[_a-z])\w{0,31})\s*$|^.*$"
Local $sString = "Valid cases are green:" & @CRLF & _
"PARAMETER_NAME" & @CRLF & _
"HELLO_WORLD" & @CRLF & _
"hello_word" & @CRLF & _
"_new_" & @CRLF & _
"_999_" & @CRLF & _
"_asdkj123123123asdasd12312312312" & @CRLF & _
"_I_am_a_32_characters_long_name" & @CRLF & _
"__hello" & @CRLF & _
"_____" & @CRLF & _
"" & @CRLF & _
"Invalid cases are not green:" & @CRLF & _
"9asdaudqwudhquwdhquwd" & @CRLF & _
"_I_am_a_33_characters_long_string" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"Valid SAS names:" & @CRLF & _
"First character is an underscore or an English letter" & @CRLF & _
"Followed by any combination of underscores, English letters and numbers" & @CRLF & _
"Max 32 characters long"
Local $sSubst = "$1"
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