#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mi)^(?>[^\w\n]*(\w++)(?=.*\R(\2?+[^\w\n]*\1\b)))+[^\w\n]*\R(?=\2[^\w\n]*$)"
Local $sString = "Rough work iconoclasm but the only way to get the truth. Oliver Wendell Holmes" & @CRLF & _
"Rough work, iconoclasm, but the only way to get the truth. Oliver Wendell Holmes" & @CRLF & _
"" & @CRLF & _
"Rule No. 1: Never lose money. Rule No. 2: Never forget rule No. 1. Warren Buffett" & @CRLF & _
"Rule No.1: Never lose money. Rule No.2: Never forget rule No.1. Warren Buffett" & @CRLF & _
"" & @CRLF & _
"Self-esteem isn't everything, it's just that there's nothing without it. Gloria Steinem " & @CRLF & _
"Self-esteem isn't everything it's just that there's nothing without it. Gloria Steinem" & @CRLF & _
"" & @CRLF & _
"You said she's a senior? Babe we're all crazy." & @CRLF & _
"You said, she's a senior! Babe we're ALL crazy." & @CRLF & _
"You said, she's a senior? Babe we're ALL crazy!" & @CRLF & _
"" & @CRLF & _
"a" & @CRLF & _
"a a" & @CRLF & _
"a a a" & @CRLF & _
"" & @CRLF & _
"a" & @CRLF & _
"a b" & @CRLF & _
"a b c" & @CRLF & _
"a b" & @CRLF & _
"a"
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