package rbq.codedemo;

import java.util.regex.Pattern;

/**
* Created by rbq on 2016/12/13.
*/

public class NumUtils {

public static boolean isNum(String str){

Pattern pattern = Pattern.compile("^-?[0-9]+");
if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}

public static boolean isNum1(String str){
//带小数的
Pattern pattern = Pattern.compile("^[-+]?[0-9]+(\\.[0-9]+)?$");

if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}

}
package rbq.codedemo;

import java.util.regex.Pattern;

/**
* Created by rbq on 2016/12/13.
*/

public class NumUtils {

public static boolean isNum(String str){

Pattern pattern = Pattern.compile("^-?[0-9]+");
if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}

public static boolean isNum1(String str){
//带小数的
Pattern pattern = Pattern.compile("^[-+]?[0-9]+(\\.[0-9]+)?$");

if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}

}

相关文章:

  • 2021-10-27
  • 2021-12-29
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-10-03
  • 2021-09-10
  • 2022-02-13
相关资源
相似解决方案