#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "\b(?:[Kk]en(?:ny2scratch)?|K2S)\b"
Local $sString = "Kenny2scratch - OK" & @CRLF & _
"kenny2scratch - OK" & @CRLF & _
"Ken - OK" & @CRLF & _
"ken - OK though not preferred" & @CRLF & _
"K2S - OK for shorthand" & @CRLF & _
"Kenny - DEFINITELY NOT OK" & @CRLF & _
"Kenny2Scratch - NOT OK because of the capital S" & @CRLF & _
"Kenny2 - NOT OK" & @CRLF & _
"k2s - NOT OK, at least capitalize it"
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