几种方法。
String a="123345";
a.matches("\\d");
///
Pattern p=Pattern.compile("ab");
String u="abcdefsfsaffsabadfewfadfgea";
Matcher m=p.matcher(u);
int i=0;
while(m.find()){
i++;
}
System.out.println(i);
用replaceAll("[a-zA-Z]+",""); 望采纳
^[-+]?[0-9]+(\.[0-9]+)?$