#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?:\s+\$\s*(?P<in_line>[^$]+?)\s*\$\s+|^\s*\${2}\s*(?P<bloc>(?:[^$]{2})*?)\s*\${2})"
Local $sString = "Lorem ipsum dolor sit ame $ a = \{ b, c \} $ Lorem 100 \$ ipsum" & @CRLF & _
"$$ \left \{ " & @CRLF & _
" \begin{array}{cl}y_1 =&3 x_1 - x_2 + x_3\\y_2 =&2 x_2\\y_3 =&x_1 - x_2 + 3 x_3\end{array} " & @CRLF & _
" \right." & @CRLF & _
" \Leftrightarrow \left \{ " & @CRLF & _
" \begin{array}{cl}8 x_1 =&3 y_1 + y_2 -y_3\\8 x_2 =&4 y_2\\8 x_3 =&-y_1 + y_2 + 3 y_3\end{array} " & @CRLF & _
" \right." & @CRLF & _
" $$ " & @CRLF & _
"Lorem ipsum dolor" & @CRLF & _
" $$ \left \{ " & @CRLF & _
" \begin{array}{cl}y_1 =&3 x_1 - x_2 + x_3\\y_2 =&2 x_2\\y_3 =&x_1 - x_2 + 3 x_3\end{array} " & @CRLF & _
" \right." & @CRLF & _
" \Leftrightarrow \left \{ " & @CRLF & _
" \begin{array}{cl}8 x_1 =&3 y_1 + y_2 -y_3\\8 x_2 =&4 y_2\\8 x_3 =&-y_1 + y_2 + 3 y_3\end{array} " & @CRLF & _
" \right." & @CRLF & _
" $$ " & @CRLF & _
"Lorem ipsum dolor $$$ Lorem ipsum dolor $$$. foo sit ame $ a = \{ b, c \} $ "
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