#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)^P(?!$)((\d+Y)|(\d+\.\d+Y$))?((\d+M)|(\d+\.\d+M$))?((\d+W)|(\d+\.\d+W$))?((\d+D)|(\d+\.\d+D$))?(T(?=\d)((\d+H)|(\d+\.\d+H$))?((\d+M)|(\d+\.\d+M$))?(\d+(\.\d+)?S)?)??$"
Local $sString = "P1Y" & @CRLF & _
"P1.4Y" & @CRLF & _
"P1.4Y2M" & @CRLF & _
"P14Y2.5M" & @CRLF & _
"P14Y2.5MT1M" & @CRLF & _
"P2MT30M" & @CRLF & _
"P2MT30.5M" & @CRLF & _
"P2MT30.5M3S" & @CRLF & _
"PT6H" & @CRLF & _
"PT6.5H" & @CRLF & _
"PT6.5H12S" & @CRLF & _
"P5W" & @CRLF & _
"P5.2W" & @CRLF & _
"P5.2W1D" & @CRLF & _
"P3Y29DT4H35M59S" & @CRLF & _
"P1Y1M1DT2H12M34.23S" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"P" & @CRLF & _
"PT" & @CRLF & _
"P3MT"
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