#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:/api|/apis/(?P<GROUP>[^/]+))/(?P<VERSION>[^/]+)(?:/namespaces/(?P<NAMESPACE>[^/]+))?/(?P<RESOURCETYPE>[^/\n]+)(?:/(?P<NAME>[^/\n]+))?(?:/(?P<SUBRESOURCE>[^/\n]+))?$"
Local $sString = "## Cluster-scoped resources" & @CRLF & _
"/api/v1/RESOURCETYPE" & @CRLF & _
"/api/v1/RESOURCETYPE/NAME" & @CRLF & _
"/apis/GROUP/VERSION/RESOURCETYPE" & @CRLF & _
"/apis/GROUP/VERSION/RESOURCETYPE/NAME" & @CRLF & _
"" & @CRLF & _
"## Namespace-scoped resources:" & @CRLF & _
"/api/v1/namespaces/NAMESPACE/RESOURCETYPE" & @CRLF & _
"/api/v1/namespaces/NAMESPACE/RESOURCETYPE/NAME" & @CRLF & _
"/apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE" & @CRLF & _
"/apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME" & @CRLF & _
"" & @CRLF & _
"## Cluster-scoped subresource:" & @CRLF & _
"/api/v1/RESOURCETYPE/NAME/SUBRESOURCE" & @CRLF & _
"/apis/GROUP/VERSION/RESOURCETYPE/NAME/SUBRESOURCE" & @CRLF & _
"" & @CRLF & _
"## Namespace-scoped subresource" & @CRLF & _
"/api/v1/namespaces/NAMESPACE/RESOURCETYPE/NAME/SUBRESOURCE" & @CRLF & _
"/apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME/SUBRESOURCE"
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