比如
private String name; //名称
结果
private String name
9 个解决方案
#1
[^a-zA-Z ]
#2
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));
}
#3
注意,二楼的答案Z后面有一个空格的,他是正确的!
鉴定完毕
#4
错了,1楼,不好意思,对不起,呵呵
#5
不好意思,看错了,===
#6
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);
#7
ls的是好方法
#8
System.out.println("private String namedfdsfdasfadsf;#####%%%^^^^&&&*****(()))".replaceAll("[^a-zA-Z\\s]",""));
#9
多谢关注,搞定
#1
[^a-zA-Z ]
#2
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));
}
#3
注意,二楼的答案Z后面有一个空格的,他是正确的!
鉴定完毕
#4
错了,1楼,不好意思,对不起,呵呵
#5
不好意思,看错了,===
#6
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);
#7
ls的是好方法
#8
System.out.println("private String namedfdsfdasfadsf;#####%%%^^^^&&&*****(()))".replaceAll("[^a-zA-Z\\s]",""));
#9
多谢关注,搞定