#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)Candidate name:\s*(Dr.|Mr.|Mrs.|Ms.)?\K.*"
Local $sString = "Candidate name:No Space" & @CRLF & _
"Candidate name: Madonna" & @CRLF & _
"Candidate name: John Smith" & @CRLF & _
"Candidate name: John Jacob Jingelheimer Schmidt" & @CRLF & _
"Candidate name: Dr. Viktor Frankenstein" & @CRLF & _
"Candidate name: Mr. Magoo" & @CRLF & _
"Candidate name: Mrs. Doubtfire" & @CRLF & _
"Candidate name: Dashy Hasa-Dasherson" & @CRLF & _
"Candidate name: Anne-Marie Hasadasher" & @CRLF & _
"Candidate name: Apostrophe O'Donnell" & @CRLF & _
"Candidate name: 尹希" & @CRLF & _
"Candidate name: 益川 敏英" & @CRLF & _
"Candidate name: Erwin Schrödinger"
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