#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "\b(\d{3})(\d{3})(\d{4})\b"
Local $sString = "reformat several 10-digit numeral strings to telephone number format" & @CRLF & _
"" & @CRLF & _
"Hello. I'm looking for regex to use with LibreOffice Calc find-and-replace function to format 10-digit numbers into telephone number format. Example: reformat " & @CRLF & _
"" & @CRLF & _
"4018286606 to be (401) 828-6606" & @CRLF & _
"" & @CRLF & _
"I tried this:" & @CRLF & _
"" & @CRLF & _
"FIND (\[0-9\]{10})" & @CRLF & _
"" & @CRLF & _
"REPLACE WITH \^(\\(\[0-9\]{3}\\)\\s\[0-9\]{3}-\[0-9\]{4})" & @CRLF & _
"" & @CRLF & _
"Not working." & @CRLF & _
"" & @CRLF & _
"Using LibreOffice [25.8.4.2](http://25.8.4.2)" & @CRLF & _
"" & @CRLF & _
"Thank you." & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = "($1) $2-$3"
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