#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(\w*)<?>?\s*=(?=(?:[^"]|"[^"]*["])*$)"
Local $sString = "import java.io.File;" & @CRLF & _
"import java.io.IOException;" & @CRLF & _
"import java.util.ArrayList;" & @CRLF & _
"import java.util.List;" & @CRLF & _
"" & @CRLF & _
"private final String COMMENTS = "test";" & @CRLF & _
"private final String VARIABLE_NAME_REGEX="(\w*)<?>?\s*=(?=(?:[^"]|"[^"]*["])*$)";" & @CRLF & _
"String test="test";" & @CRLF & _
"String test222;" & @CRLF & _
"String includeThisAlso ;" & @CRLF & _
"List <String> arr;" & @CRLF & _
"List <String> list=null;" & @CRLF & _
""
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