#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "<([^\/> ]+)\s*([^>]*)\s*(?:\/>|>(.*)<\/\1>)"
Local $sString = "<tag attrib="text" attrib2 = "othertext"><innertag>value</innertag></tag>" & @CRLF & _
"<tag2 />" & @CRLF & _
"<tag3/>" & @CRLF & _
"<tag4>value</tag4>" & @CRLF & _
"<tag5></tag5>" & @CRLF & _
"<tag2 attrib="text" attrib2 = "othertext" />" & @CRLF & _
"<tag3 attrib="text" attrib2 = "othertext"/>" & @CRLF & _
"<tag5 attrib="text" attrib2 = "othertext"></tag5>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<([^\/> ]+)\s*([^>]*)\s*(?:\/>|>(.*)<\/\1>) (with global) finds all tags in scope" & @CRLF & _
"" & @CRLF & _
"1st group is tagname" & @CRLF & _
"2nd group is attributes" & @CRLF & _
"3rd group (if it exists) is value of the tag" & @CRLF & _
"" & @CRLF & _
"Apply pattern again on 3th group to find internal tags (recurse in the code to parse entire xml!)" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"Apply pattern below on 2nd group to find all attributes:" & @CRLF & _
"" & @CRLF & _
"\s+([^<>\=" ]+)\s*=\s*"([^"]*)" (with global) finds attributes" & @CRLF & _
"" & @CRLF & _
" 1st group is attributename" & @CRLF & _
" 2nd group is attributevalue"
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