#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(?:\[[A-Z]*-\d* \/fixed\] )?(?<type>\w*)(?:\((?<scope>[\w$.\-*\/ ]*)\))?: (?<subject>(?:.(?!(?i)\/fixed))*)$"
Local $sString = "# without scope" & @CRLF & _
"feat: add REST endpoint /my-app/api/versions" & @CRLF & _
"fix: change git commit username" & @CRLF & _
"style: set indentation to 4 spaces" & @CRLF & _
"docs: explain new configuration preset" & @CRLF & _
"" & @CRLF & _
"# with scope" & @CRLF & _
"feat(backend): add REST endpoint /my-app/api/versions" & @CRLF & _
"fix(default): change git commit username" & @CRLF & _
"style(npm): set indentation to 4 spaces" & @CRLF & _
"docs(terraform): explain new configuration preset" & @CRLF & _
"" & @CRLF & _
"# smartcommit without scope" & @CRLF & _
"[CORE-1234 /fixed] feat: add REST endpoint /my-app/api/versions" & @CRLF & _
"[HDEFECT-1234 /fixed] fix: change git commit username" & @CRLF & _
"[HDEFECT-1234 /fixed] style: set indentation to 4 spaces" & @CRLF & _
"[HDEFECT-1234 /fixed] docs: explain new configuration preset" & @CRLF & _
"" & @CRLF & _
"# smartcommit with scope" & @CRLF & _
"[CORE-1234 /fixed] feat(backend): add REST endpoint /my-app/api/versions" & @CRLF & _
"[HDEFECT-1234 /fixed] fix(default): change git commit username" & @CRLF & _
"[HDEFECT-1234 /fixed] style(npm): set indentation to 4 spaces" & @CRLF & _
"[HDEFECT-1234 /fixed] docs(terraform): explain new configuration preset" & @CRLF & _
"" & @CRLF & _
"# not match - wrong smart commit" & @CRLF & _
"[core-1234 /fixed] feat(backend): add REST endpoint /my-app/api/versions" & @CRLF & _
"[hdefect-1234 /fixed] fix(default): change git commit username" & @CRLF & _
"[hdefect-1234 /fixed] style(npm): set indentation to 4 spaces" & @CRLF & _
"[hdefect-1234 /fixed] docs(terraform): explain new configuration preset" & @CRLF & _
"" & @CRLF & _
"# not matched - use /fixed in title " & @CRLF & _
"[CORE-1234 /fixed] feat(backend): add REST endpoint /my-app/api/versions /fixed" & @CRLF & _
"[HDEFECT-1234 /fixed] fix(default): change git commit /fixed username" & @CRLF & _
"[HDEFECT-1234 /fixed] style(npm): set /FIXED indentation to 4 spaces" & @CRLF & _
"[HDEFECT-1234 /fixed] docs(terraform): /fixed explain new configuration preset" & @CRLF & _
""
Local $sSubst = "$type $scope $subject"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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