#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?Jx)(?<sup_all>" & @CRLF & _
" (?:" & @CRLF & _
" (?<!\\)\^" & @CRLF & _
" (?<sup_text>" & @CRLF & _
" (?>\\[\^[:blank:]\h]|[^\^[:blank:]\h\v])*+" & @CRLF & _
" )" & @CRLF & _
" (?<!\\)\^" & @CRLF & _
" )" & @CRLF & _
" |" & @CRLF & _
" (?: # or the Microsoft way. Beurk" & @CRLF & _
" \<sup\>" & @CRLF & _
" (?<sup_text>" & @CRLF & _
" ((?!\v).)+" & @CRLF & _
" )" & @CRLF & _
" \<\/sup\>" & @CRLF & _
" )" & @CRLF & _
")"
Local $sString = "2^10^ is 1024." & @CRLF & _
"" & @CRLF & _
"Space is not allowed:" & @CRLF & _
"P^a cat^" & @CRLF & _
"" & @CRLF & _
"But it's ok if it is escaped" & @CRLF & _
"P^a\ cat^" & @CRLF & _
"" & @CRLF & _
"Line break is a no-no, even escaped" & @CRLF & _
"P^a\" & @CRLF & _
" cat^" & @CRLF & _
"" & @CRLF & _
"Hmm <sup>This is a Microsoft superscript!</sup>" & @CRLF & _
"" & @CRLF & _
"H^2^0" & @CRLF & _
"" & @CRLF & _
"text^a\ superscript^" & @CRLF & _
""
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