#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?<firstchar>(?=[A-Za-z]))((?<alphachars>[A-Za-z])|(?<specialchars>[A-Za-z]['-](?=[A-Za-z]))|(?<spaces> (?=[A-Za-z])))*$"
Local $sString = "#First Name must contain letters only. It may contain spaces, hyphens, or apostrophes." & @CRLF & _
"First name-and hy-phen's" & @CRLF & _
"#It must begin with letters." & @CRLF & _
"First name" & @CRLF & _
"1shouldn't match" & @CRLF & _
"'shouldn't match" & @CRLF & _
"#All other characters and numbers are not valid." & @CRLF & _
"Should match" & @CRLF & _
"Should not m@tch" & @CRLF & _
"Should not m#tch" & @CRLF & _
"#Special characters ‘ and – cannot be together (e.g. John’-s is not allowed)" & @CRLF & _
"Allow'd" & @CRLF & _
"NotAllow-'d" & @CRLF & _
"NotAllow'-d" & @CRLF & _
"#An alphabet should be present before and after the special characters ‘ and – (e.g. John ‘s is not allowed)" & @CRLF & _
"Allow'd" & @CRLF & _
"Also A'llowed" & @CRLF & _
"A'llowd" & @CRLF & _
"Not Allowd'" & @CRLF & _
"Not 'Allowd" & @CRLF & _
"#Two consecutive spaces are not allowed (e.g. Annia St is not allowed)" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
""
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