#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)^(?![^'\-_\n]*['\-_][^'\-_\n]*['\-_])[a-z .',-_]+$"
Local $sString = "It should be valid if a Surname is:" & @CRLF & _
"abcd" & @CRLF & _
"abcd'efg" & @CRLF & _
"abcd-efg" & @CRLF & _
"abcd, .efg" & @CRLF & _
"etc..." & @CRLF & _
"" & @CRLF & _
"I also need to test if symbols do not repeat... so for example:" & @CRLF & _
"" & @CRLF & _
"abcd''efg" & @CRLF & _
"abcd-'," & @CRLF & _
"" & @CRLF & _
"Are invalid but the one:" & @CRLF & _
"" & @CRLF & _
"abcd, .efg" & @CRLF & _
"" & @CRLF & _
"Can be valid." & @CRLF & _
"" & @CRLF & _
"At the moment I just created this:" & @CRLF & _
"" & @CRLF & _
"^[a-z .',-_]+$" & @CRLF & _
"And now I'm trying to check for all the double symbols but I cannot go ahead successfully." & @CRLF & _
"" & @CRLF & _
"Mc'Millan, .jr"
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