#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)((\b\w+(?:\s+\w+)*\b)(?:\s+\w+)*)\s+\2\b"
Local $sString = "REGEXP_REPLACE([Product], "(\b\w+\b)(?=\s+\b\1\b)", "")" & @CRLF & _
"" & @CRLF & _
"but it only removes the duplicate when they are right beside each other so the "Blue Blue Car" is fixed" & @CRLF & _
"to "Blue Car" but it doesn't fix "Wild Yellow Wild Yellow Ball" Because they are not right" & @CRLF & _
"beside each other" & @CRLF & _
"Wild Yellow Bouncy Ball Wild Yellow" & @CRLF & _
""
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