public boolean hasDigit(String content){ boolean flag=false; Pattern p=Pattern.compile(".*\\d+.*"); Matcher m=p.matcher(content); if (m.matches()) { flag=true; } return flag; }