#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(((I|i)nitial|(F|f)irst)\scommit)|((I|i)nit)$|^(?=.{6,72}$)(feat|(bug|hot)?fix|docs|perf|style|wip|test|revert|chore|ci|refactor|build)(\([a-zA-Z0-9\-\s,]{1,50}\))?:\s(.{1,50})$"
Local $sString = "?# https://www.conventionalcommits.org/en/v1.0.0/" & @CRLF & _
"" & @CRLF & _
"Initial commit" & @CRLF & _
"initial commit" & @CRLF & _
"Init" & @CRLF & _
"init" & @CRLF & _
"First commit" & @CRLF & _
"first commit" & @CRLF & _
"" & @CRLF & _
"?# Correct" & @CRLF & _
"feat(foo): new feature" & @CRLF & _
"bugfix(bar): fix this and that" & @CRLF & _
"docs(foo): document new feature" & @CRLF & _
"docs(foo, egg): multiple scopes is fine" & @CRLF & _
"feat: no scope here" & @CRLF & _
"" & @CRLF & _
"?# Wrong" & @CRLF & _
"" & @CRLF & _
"feat:missing a space" & @CRLF & _
"docs(): no empty scope" & @CRLF & _
"fix(/.%): invalid characters" & @CRLF & _
"Initial" & @CRLF & _
"initial" & @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