#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?i)(?<!\b(?:inc|pease|nope|U.S.A|u.s.w))([.?!]\s+)(\w)"
Local $sString = "U.S.A. is the country? i want to live in. if you please. yes. nope." & @CRLF & _
"U.S.A. is the country? i want to live inc. if you pease. dope. yes." & @CRLF & _
"U.S.A. is the country? i want to live Inc. if you pease. dope. yes." & @CRLF & _
"" & @CRLF & _
"u.s.w. and so on. a German abbreviation." & @CRLF & _
"U.s.w. and so on. a German abbreviation." & @CRLF & _
"" & @CRLF & _
"// str" & @CRLF & _
"// .replace(" & @CRLF & _
"// (/(?<!\b(?:inc|pease|nope|U.S.A|u.s.w))([.?!]\s+)(\w)/gi)," & @CRLF & _
"// (_, $1, $2) => $1 + $2.toUpperCase()" & @CRLF & _
"// );" & @CRLF & _
"// ... or ..." & @CRLF & _
"// str" & @CRLF & _
"// .replace(" & @CRLF & _
"// (/(?<!inc|pease|nope|U.S.A|u.s.w)([.?!]\s*)(\w)/gi)," & @CRLF & _
"// (_, $1, $2) => $1 + $2.toUpperCase()" & @CRLF & _
"// )" & @CRLF & _
"// .replace((/U\.S\.W\./g), 'u.s.w.');" & @CRLF & _
""
Local $sSubst = "$1$2"
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