#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?P<MC>mc16[acde])\.(?P<SHORTNAME>.+?)\.(?P<MXAODFLAVOUR>MxAOD.+?)\.(e[0-9]+_s[0-9]+_r[0-9]+)?_?(?P<PTAG>p[0-9]+)(?:\.(?P<HTAG>h[0-9]+(?:-\w+?)?))?(?:(?:\.|_)(?P<N>[0-9]+))?\.root"
Local $sString = "mc16a.MGPy8_tHjb125_yt_plus1.MxAODDetailed.e4606_s3126_r9364_p3665.root" & @CRLF & _
"mc16a.PowhegPy8_NNPDF30_VBFH125.MxAODDetailed.e5720_s3126_r9364_p3665.root" & @CRLF & _
"mc16a.PowhegPy8_NNLOPS_ggH125.MxAODDetailed.e5607_s3126_r9364_p3665.root" & @CRLF & _
"mc16a.PowhegPy8_NNLOPS_ggH125.MxAODDetailed.e5607_s3126_r9364_p3665.h024.root" & @CRLF & _
"mc16d.PowhegH7_NNLOPS_ggH125.MxAODDetailed.p3524.h021-pid.root" & @CRLF & _
"mc16a.MGPy8_ttgamma_nonallhadronic_AF2.MxAODDetailed.p3469.h019.root" & @CRLF & _
"mc16a.PowhegPy8_NNPDF30_VBFH125.MxAODLeptonMETSys.p3404.h019.004.root"
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