InputCheckUtils.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.aoyang.tms.util;
  2. import org.apache.commons.lang3.StringUtils;
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5. import static java.util.regex.Pattern.compile;
  6. /**
  7. * @Description: 输入项校验
  8. * @Author guoyong
  9. * @Date 2020/10/21 14:37
  10. * @Version 1.0
  11. */
  12. public class InputCheckUtils {
  13. /**
  14. * @Author guoyong
  15. * @Description 判断是否数字和字符组合
  16. * @Date 2020/10/21
  17. * @Param
  18. * @return
  19. **/
  20. public static boolean isLetterDigit(String str) {
  21. String regex = "^[a-z0-9A-Z]+$";
  22. return str.matches(regex);
  23. }
  24. /**
  25. * 是否是数字或小数
  26. * @tags @return
  27. * @exception
  28. * @author wanghc
  29. * @date 2015-9-16 下午5:50:15
  30. * @return boolean
  31. */
  32. public static boolean isNumber(String str){
  33. if(StringUtils.isBlank(str)){
  34. return false;
  35. }
  36. String reg = "\\d+(\\.\\d+)?";
  37. return str.matches(reg);
  38. }
  39. public static boolean isCarNo(String carNo){
  40. Pattern p = compile("^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(?:(?![A-Z]{4})[A-Z0-9]){4}[A-Z0-9挂学警港澳]{1}$");
  41. Matcher m = p.matcher(carNo);
  42. if (!m.matches()){
  43. return false;
  44. }
  45. return true;
  46. }
  47. }