#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^\+?(?![^ \n-]*[ -]{2})(?=(?:[ -]*\d){10,12}$)\d[\d -]*\d$"
Local $sString = "+12 1234567890" & @CRLF & _
"+12 12 345 567 89" & @CRLF & _
"+12 123-455-6789" & @CRLF & _
"+9712345567" & @CRLF & _
"" & @CRLF & _
"Additional good" & @CRLF & _
"9712345567" & @CRLF & _
"" & @CRLF & _
"Additional bad" & @CRLF & _
"+9712345- - 567" & @CRLF & _
"+9712345678 " & @CRLF & _
" +9712345678" & @CRLF & _
"+ 9712345678" & @CRLF & _
"+97--12345678" & @CRLF & _
"" & @CRLF & _
"+1234567890123" & @CRLF & _
"+123456789" & @CRLF & _
"" & @CRLF & _
"The regex is for validating phone numbers so it should have minimum length 10 digits and maximum length of 12 digits except special symbols like +, - and space." & @CRLF & _
"Plus sign only allowed at start. I tried below regex but not working for me."
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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