#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)‘(?!(?:“[^”\n]*”|[^‘”\n])*’(?![a-z]))"
Local $sString = "“double-quote,” and some text" & @CRLF & _
"Some text and “double-quote” and an ‘orphan" & @CRLF & _
"“double-quote,” some text and ‘matched l/rsquo’" & @CRLF & _
"Some text and “double-quote” and an ‘orphan and an ’elided word" & @CRLF & _
"“double-quote,” ‘matched l/rsquo’ and an ‘orphan and ’elided word" & @CRLF & _
"Some text, “double-quote,” more text, an ‘orphan and a contract’n" & @CRLF & _
"“double-quote,” some text, and another “double quote.”" & @CRLF & _
"“double-quote,” some text, an ‘orphan and “another double-quote”" & @CRLF & _
"“double-quote,” a ‘matched l/rsquo with an “embedded double-quote” in it.’" & @CRLF & _
"“double-quote,” a ‘matched l/rsquo with an “embedded double-quote” in it’ and an ‘orphan." & @CRLF & _
"“double-quote,” some text, an ‘orphan, a contract’n, and “another double-quote”" & @CRLF & _
"“double-quote,” some text, another “double-quote,” an ‘orphan and a contract’n" & @CRLF & _
"“double-quote” and “another double-quote” and an ‘orphan and ‘another lsquo" & @CRLF & _
"“double-quote” and some text and an ‘orphan and ‘a matched l/rsquo’" & @CRLF & _
"Some text and “double-quote” and an ‘orphan and ‘a matched l/rsquo with a contract’n’" & @CRLF & _
"some text and an ‘orphan" & @CRLF & _
"some text and an ‘orphan and an ’elided word" & @CRLF & _
"some text and an ‘orphan and a contract’n" & @CRLF & _
"some text ‘orphan, another ‘lsquo, and more text" & @CRLF & _
"some text ‘orphan, a contract’n, another ‘lsquo and ’elided word and more text" & @CRLF & _
"some text, an ‘orphan and a “double-quote with ‘matching l/rsquo’” and more text" & @CRLF & _
"" & @CRLF & _
"Some text, “double quote, with an ‘orphan inside.”" & @CRLF & _
"Some text, “double quote, with a ‘matched l/rsquo inside.’”" & @CRLF & _
"Some text, “double quote, with an ‘orphan and contract’n inside.”" & @CRLF & _
"Some text, “double quote, with an ‘orphan and ’elided word inside.”" & @CRLF & _
"Some text, “double quote, with an ‘orphan and ‘matched l/rsquo inside.’”" & @CRLF & _
"“‘Orphan immediately following double-quote.”" & @CRLF & _
"“‘Matching l/rsquo immediately inside double-quote.’”" & @CRLF & _
"“‘Orphan immediately following double-quote with ‘matched l/rsquo’ inside.”" & @CRLF & _
"“Double quote,” another “double quote with an ‘orphan and ‘matched l/rsquo’”" & @CRLF & _
"“double quote,” another “double quote with an ‘orphan and contract’n and ‘matched l/rsquo’ and more text”"
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