Http://www.cnblogs.com/zhangj95/p/4198822.html
Http://www.cnblogs.com/sunzn/archive/2013/07/12/3186518.html
Reference:
1 packagecn.sunzn.demo;2 3 Importjava.util.regex.Matcher;4 Importjava.util.regex.Pattern;5 6 public classDemo {7 public Static voidmain (string[] Args) {8System.out.println (iscontainchinese ("china")));9 }Ten one public Static BooleanIscontainchinese (String Str) { a -Pattern p = pattern.compile ("[\u4e00-\u9fa5]"); -Matcher m =P.matcher (str); the if(m.find ()) { - return true; - } - return false; + } -}
In my own case, find works.
1 packagesdf;2 3 Importjava.util.regex.Matcher;4 Importjava.util.regex.Pattern;5 6 public classD {7 8 public Static Booleanisnumeric (String Str) {9 for(inti = Str.length (); I. >= 0;) {Ten if(!character.isdigit (str.charat (i))) { one return false; a } - } - return true; the } - public Static voidmain (string[] Args) { - //TODO auto-generated Method Stub - +String s1= "25"; -String s2= "retake"; +Pattern pattern = Pattern.compile ("\\d+"); a atMatcher Matcher1 =Pattern.matcher (s1); - //boolean b1= matcher1.matches (); - Booleanb1=Matcher1.find (); - System.out.println (b1); - -Matcher Matcher2 =Pattern.matcher (s2); in //boolean b2= matcher2.matches (); - BooleanB2=Matcher2.find (); to System.out.println (b2); + - //System.out.println (isnumeric (s1)); the //System.out.println (isnumeric (s2)); * $ }Panax Notoginseng -}
Whether there are numbers in the Java string