#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?:(?<!\w)'((?:.|\n)+?'?)'(?!\w))"
Local $sString = "'Wow' I'm one of the persons' stackoverflow don't th'em said, 'hey what' I'll handle it." & @CRLF & _
"'Don't do that' he said." & @CRLF & _
"Similar to the 'Kumbh melas', celebrated by the banks of the holy rivers of India." & @CRLF & _
"'Hey'! you'll, I'm, he's, " & @CRLF & _
"some random text" & @CRLF & _
"'what if it's" & @CRLF & _
"multiline?'" & @CRLF & _
"" & @CRLF & _
"'I'm one of the persons''" & @CRLF & _
"" & @CRLF & _
"'I'm one of the persons''"
Local $sSubst = ""\1""
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