#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^([0-9]{3})-?([0-9]{3})-?([0-9]{3})-?([0-9]{3})?$"
Local $sString = "009026405" & @CRLF & _
"01009556500" & @CRLF & _
"226-356-839" & @CRLF & _
"00829029200" & @CRLF & _
"008-018-454" & @CRLF & _
"009-513-213" & @CRLF & _
"00383951900" & @CRLF & _
"000147765000" & @CRLF & _
"96029000672" & @CRLF & _
"008-743-791" & @CRLF & _
"009568337" & @CRLF & _
"136759989000" & @CRLF & _
"009724967000" & @CRLF & _
"2RC0001624466" & @CRLF & _
"286169755000" & @CRLF & _
"201-947-430-0" & @CRLF & _
"241402504000" & @CRLF & _
"223651060000" & @CRLF & _
""
Local $sSubst = "[$1.$2.$3.${4:+$4:000}]"
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