#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mx)^(\+?\d[\h(-]{0,3})? # Remove country code, "+", " ", and "("" & @CRLF & _
"(\d{3}) # Area code" & @CRLF & _
"[\h)-.]{0,3} # Remove "-", " ", ".", and ")"" & @CRLF & _
"(\d{3}) # Three digits" & @CRLF & _
"[\h-.]{0,3} # Remove "-", " ", and "."" & @CRLF & _
"(\d{4}) # Four digits"
Local $sString = "+1 123 111 1111" & @CRLF & _
"+1-111-111-1234" & @CRLF & _
"+1 (111) 111-1111" & @CRLF & _
"1 111 111 1111" & @CRLF & _
"1-111-111-1111" & @CRLF & _
"1-(111) 111-4567" & @CRLF & _
"1111111111" & @CRLF & _
"111.111.8765" & @CRLF & _
"111-345-1111"
Local $sSubst = "$2.$3.$4"
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