#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?sx) # Free-Spacing" & @CRLF & _
"(?(DEFINE) # Define a few subroutines" & @CRLF & _
" (?<double>“(?:(?!&[lr]squo;).)*”) # full set of doubles (no quotes inside)" & @CRLF & _
" (?<single>‘(?:(?!&[lr]dquo;).)*’) # full set of singles (no quotes inside)" & @CRLF & _
" (?<notquotes>(?:(?!&[lr][sd]quo;).)*) # chars that are not quotes" & @CRLF & _
") # end DEFINE" & @CRLF & _
"" & @CRLF & _
"^ # Start of string" & @CRLF & _
"(?: # Start non-capture group" & @CRLF & _
" (?¬quotes) # Any non-quote chars" & @CRLF & _
" &l(?<type>[sd])quo; # Opening quote, capture single or double type" & @CRLF & _
" # any full singles, doubles, not quotes or recursion" & @CRLF & _
" (?:(?&single)|(?&double)|(?¬quotes)|(?R))*" & @CRLF & _
" &r\k<type>quo; # Closing quote of the correct type" & @CRLF & _
")*+ # Repeat non-capture group" & @CRLF & _
"(?¬quotes)" & @CRLF & _
"\K" & @CRLF & _
"&[lr][sd]quo; # unmatched quote" & @CRLF & _
""
Local $sString = "“Full Quote” The Left Quote is Missing”" & @CRLF & _
""
Local $sSubst = ""
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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