#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)\A(?:(?P<type>[^\(!:]+)(?:\((?P<scope>[^\)]+)\))?(?P<breaking>!)?: (?P<description>.+))(?:(?!(?:\n{2}^(?:BREAKING[ -]CHANGE|[a-zA-Z0-9_\-]+)(?:: | #\b)[^\n:]+(\n*\b)?)+)\n{2}(?P<body>(?:(?!\n{2}(?:^(?:BREAKING[ -]CHANGE|[a-zA-Z0-9_\-]+)(?:: | #\b)[^\n:]+(\n*\b)?)+).|\n+?)+?))?(?:\n{2}(?P<footers>(?:^(?:BREAKING[ -]CHANGE|[a-zA-Z0-9_\-]+)(?:: | #\b)[^\n:]+(\n*\b)?)+))?(?:\n*)\Z"
Local $sString = "feat(foo): add a nice RegEx to check and parse a commit message that folows https://www.conventionalcommits.org/en/v1.0.0" & @CRLF & _
"" & @CRLF & _
"Hello, " & @CRLF & _
"" & @CRLF & _
"This is an" & @CRLF & _
"multiline example and very nice" & @CRLF & _
"" & @CRLF & _
"This may also include colons as long as they are not after a word boundary followed after two line brakes" & @CRLF & _
"Example: foo" & @CRLF & _
"" & @CRLF & _
" Other example: xyz" & @CRLF & _
"" & @CRLF & _
"Refs: #42" & @CRLF & _
"BREAKING-CHANGE: Brakes wood" & @CRLF & _
"something #mentions a commit"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; 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