#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)\b(課長(?:補佐(?:代理(?:心得)?)?)?)\b"
Local $sString = "課長補佐、課長補佐代理、課長補佐代理心得" & @CRLF & _
"" & @CRLF & _
"課長心得、課長代理" & @CRLF & _
"" & @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