62,616
社区成员
发帖
与我相关
我的任务
分享
public class StringQuery {
public static void main(String[] args) {
String temp = "";
String str = "+5678";
Pattern p = Pattern.compile("[0-9]+");
Matcher m = p.matcher(str);
while (m.find()) {
temp += m.group() + "";
}
System.out.println(temp);
}
}
s2 = s1.replaceAll("^\\+", "");
s2 = s1.replaceAll("^\\+*", "");
String s1 = "2+3+4";
String s2 = s1.replaceAll("\\+", "");