1.现象
String newStrRegrex = ".*String\\(.*\\,.*\\).*";
String line3 = "String returnMessage = new String(arr,\"gbk\");\n";
String line2 = "String returnMessage = new String(arr,\"gbk\");";
line3.matches(newStrRegrex) 返回false;
line2.matches(newStrRegrex) 返回true;
2.原因
"\n".matches(".*")
返回false ,.*不能匹配换行符
3.解决方案
先去除换行符再进行匹配