#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mxJ)(?<!\\) # Check it was not escaped with a \" & @CRLF & _
"(?<img_all>" & @CRLF & _
" \!\[(?<img_alt>.+?)\] # image alternative text, i.e. the text used when the image does not" & @CRLF & _
" (?:" & @CRLF & _
" (?:" & @CRLF & _
" [ ]? # possibly followed by some spaces" & @CRLF & _
" (?:\n[ ]*)? # and a new line with some space" & @CRLF & _
" \[(?<img_id>.*?)\] # with the link id in brackets, but may be empty" & @CRLF & _
" )" & @CRLF & _
" |" & @CRLF & _
" (?:" & @CRLF & _
" (?:" & @CRLF & _
" \(" & @CRLF & _
" [ \t]*" & @CRLF & _
" <(?<img_url> # link url within <>; or" & @CRLF & _
" .+?" & @CRLF & _
" )>" & @CRLF & _
" [ \t]* # possibly followed by some spaces or tabs" & @CRLF & _
" (?:" & @CRLF & _
" (?<img_title_container>['"]) # Title is surrounded ether by double or single quotes" & @CRLF & _
" (?<img_title>.*?) # actual title, but could be empty as in """ & @CRLF & _
" \g{img_title_container} # make the sure enclosing mark balance" & @CRLF & _
" )?" & @CRLF & _
" [ \t]*" & @CRLF & _
" \)" & @CRLF & _
" )" & @CRLF & _
" |" & @CRLF & _
" (?:" & @CRLF & _
" \(" & @CRLF & _
" [ \t]*" & @CRLF & _
" (?<img_url> # link url within <>; or" & @CRLF & _
" (?:((?!["']).)*+|.*)" & @CRLF & _
" )" & @CRLF & _
" [ \t]*" & @CRLF & _
" (?:" & @CRLF & _
" (?<img_title_container>['"]) # Title is surrounded ether by double or single quotes" & @CRLF & _
" (?<img_title>.*?) # actual title, but could be empty as in """ & @CRLF & _
" \g{img_title_container} # make the sure enclosing mark balance" & @CRLF & _
" )?" & @CRLF & _
" [ \t]*" & @CRLF & _
" \)" & @CRLF & _
" )" & @CRLF & _
" )" & @CRLF & _
" )" & @CRLF & _
" [ \t]*" & @CRLF & _
" (?<!\\)" & @CRLF & _
" \{" & @CRLF & _
" [[:blank:]\h]*" & @CRLF & _
" (?<img_attr>.+?)" & @CRLF & _
" [[:blank:]\h]*" & @CRLF & _
" \}" & @CRLF & _
")"
Local $sString = "This is an {.class #inline-img}." & @CRLF & _
"" & @CRLF & _
".jpg'Title here') {.class #inline-img} and some text after" & @CRLF & _
"" & @CRLF & _
" {.class #inline-img}" & @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