#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?P<str_lit>(?P<begin_quote>(?P<single_quote>')|\")(?:(?(single_quote)\"|')|\\[\"']|\\[^\r\n ]|[^\"'\\\r\n])*?(?P=begin_quote))$"
Local $sString = ""double-quoted string"" & @CRLF & _
"'single-quoted string'" & @CRLF & _
""unexpected EOL" & @CRLF & _
"'unexpected EOL" & @CRLF & _
""unclosed backslash escape: \"" & @CRLF & _
""properly doubled backslash: \\"" & @CRLF & _
""escaped ' quotes and backslash escapes \' are \" \n allowed"" & @CRLF & _
""\t\tindented code\r\n"" & @CRLF & _
""invalid escape \%"" & @CRLF & _
""'"" & @CRLF & _
""space is not a valid backslash escape: \ "" & @CRLF & _
""or newline either: \" & @CRLF & _
""hopefully there aren't any edge-cases I didn't think of"" & @CRLF & _
""""oh, and single-line docstrings count as three string literals, so you would have to repeat the same expression multiple times to match it"""" & @CRLF & _
""""and multi-line docstrings won't match even if you repeat the expression multiple times"
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