java利用正则截取字符串中的数字
生活随笔
收集整理的這篇文章主要介紹了
java利用正则截取字符串中的数字
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
java利用正則截取字符串中的數(shù)字
String str = "xxx第47297章33";String regex = "\\d*";Pattern p = Pattern.compile(regex);Matcher m = p.matcher(str);while (m.find()) { if (!"".equals(m.group()))System.out.println("come here:" + m.group()); }
打印結(jié)果為
come here:47297 come here:33 ?
?
?
?
?
?
posted on 2013-03-26 09:25?liangge0218 閱讀(...) 評論(...) 編輯 收藏轉(zhuǎn)載于:https://www.cnblogs.com/liangge0218/archive/2013/03/26/3292379.html
總結(jié)
以上是生活随笔為你收集整理的java利用正则截取字符串中的数字的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2012 Microsoft Inter
- 下一篇: 技术面试过程