#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ms)^(([A-Z][a-z]+)(?=[\ ])|([A-Z][a-z]*[\'\-])(?=[A-Z]?[a-z]+)|([A-Z][a-z]+)(?![\ '\-])|(?<=[\'\-])([a-z]+)|(?<=[a-z])([\ ])(?=[A-Z]))+$"
Local $sString = "Kamal Manil" & @CRLF & _
"Kamal O'Neil" & @CRLF & _
"Kamal Manil Malaka" & @CRLF & _
"Kamal Al-Shaba" & @CRLF & _
"Al-shaba" & @CRLF & _
"O'neil" & @CRLF & _
"Ol'Neil" & @CRLF & _
"Jo Jo" & @CRLF & _
"Jo" & @CRLF & _
"" & @CRLF & _
" Kamal Manil" & @CRLF & _
"Kamal O' Neil" & @CRLF & _
"Kamal Manil Malaka " & @CRLF & _
"Kamal Al- Shaba" & @CRLF & _
"Al -shaba" & @CRLF & _
"O 'neil" & @CRLF & _
"Jo Jo" & @CRLF & _
"A B C Jo" & @CRLF & _
"Kamal SDF -''''sdf''- " & @CRLF & _
" " & @CRLF & _
"A" & @CRLF & _
"a" & @CRLF & _
"A B" & @CRLF & _
"-Shana" & @CRLF & _
"'Neil" & @CRLF & _
"-shaba" & @CRLF & _
"'neil" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"([A-Z][a-z]+(?![\'\-]))"
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