62,623
社区成员
发帖
与我相关
我的任务
分享
String teststr = "private String namedfdsfdasfadsf;#####%%%^^^^&&&*****(()))";
String testreg = "[^a-zA-Z\\s]";
Pattern matchsip = Pattern.compile(testreg);
Matcher mp = matchsip.matcher(teststr);
teststr = mp.replaceAll("");
System.out.println(teststr);
String teststr = "private String name;";
String testreg = "(?s)(.*?)(?:;)";
Pattern matchsip = Pattern.compile(testreg);
Matcher mp = matchsip.matcher(teststr);
while(mp.find()){
System.out.println(mp.group(1));
}