#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(([\|&]|return|[^=<>|\*]=|\(|\[)\s*)([a-zA-Z\._]+)\s*\?\s*\3\s*:\s*"
Local $sString = "SHOULD NOT MATCH" & @CRLF & _
"(value <= low ? low : (value >= high ? high : value))" & @CRLF & _
"" & @CRLF & _
"SHOULD MATCH" & @CRLF & _
"res = a || b?b:c" & @CRLF & _
"res = a || b?b:c?c:d" & @CRLF & _
"res = a?a:b?b:c?c:d?d:e?e:"f"" & @CRLF & _
"res = a?a:b?b: c?c: d?d : e ?e : "f"" & @CRLF & _
"return GLOB.using_map.system_name ? GLOB.using_map.system_name : generate_system_name()" & @CRLF & _
"foo = bar ? bar : "john"" & @CRLF & _
"var=joo?joo:juu" & @CRLF & _
"proc(foo? foo : bar)" & @CRLF & _
"if(baz?baz:car)"
Local $sSubst = "\1\3 || "
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