日期:2014-05-20  浏览次数:20819 次

正则表达式关于indexOf找出是否含有数字,求解~
if(inputStr.indexOf("\\d+")<0)

这样子返回的怎么都是-1啊???
求解~

------解决方案--------------------
用正则吧:

public static boolean isHasDigital(String checkStr) {
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(checkStr);
boolean match = matcher.find();
if (match) {
return true;
}
return false;
}