String temp = "ww34mnwe798sq中文ad84";
从此字符串中提取数字:34、798、84.
 请各位高手看看。

解决方案 »

  1.   


    public static void main(String[] args) throws Exception {
    String temp = "ww34mnwe798sq中文ad84";
    String[] tmp = temp.replaceAll("[^\\d]+",",").split(",");
    for (String string : tmp) {
    if(string.matches("\\d+")){
    System.out.println(string);
    }
    }
    }
      

  2.   

    String temp = "ww34mnwe798sq中文ad84";
    Pattern p = Pattern.compile("\\d+");
    Matcher m = p.matcher(temp);
    while(m.find()){
        System.out.println(m.group());
    }
      

  3.   

    String[] tmp = temp.split("\\D.");
    这样就行了吧。楼上,你说呢?
      

  4.   

    如果截取到汉字的时候就要出问题了 
    所以需要先转换成byte 再进行判断截取
      

  5.   

    不好意思写错了,应该
    String[] tmp = temp.split("\\D+");
      

  6.   


    public class Test1 {
    public static void main(String[] args) {
    String s = "fdf12ffdew32ww21ww中文55ww";
    String[] temp = s.split("\\D+");
    for(String str : temp) {
    System.out.print(str);
    }
    }
    }