Android开发中正则表达式工具类RegexUtil的示例分析

小编给大家分享一下Android开发中正则表达式工具类RegexUtil的示例分析,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

高密网站建设公司成都创新互联,高密网站设计制作,有大型网站制作公司丰富经验。已为高密上千提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的高密做网站的公司定做!

具体如下:

/***********************************************
 * 正则表达式工具
 *
 * @author chen.lin
 * @version 1.0
 ************************************************/
public class RegexUtil {
  /**
   * 车牌号码Pattern
   */
  public static final Pattern PLATE_NUMBER_PATTERN = Pattern
      .compile("^[\u0391-\uFFE5]{1}[a-zA-Z0-9]{6}$");
  /**
   * 证件号码Pattern
   */
  public static final Pattern ID_CODE_PATTERN = Pattern
      .compile("^[a-zA-Z0-9]+$");
  /**
   * 编码Pattern
   */
  public static final Pattern CODE_PATTERN = Pattern
      .compile("^[a-zA-Z0-9]+$");
  /**
   * 固定电话编码Pattern
   */
  public static final Pattern PHONE_NUMBER_PATTERN = Pattern
      .compile("0\\d{2,3}-[0-9]+");
  /**
   * 邮政编码Pattern
   */
  public static final Pattern POST_CODE_PATTERN = Pattern.compile("\\d{6}");
  /**
   * 面积Pattern
   */
  public static final Pattern AREA_PATTERN = Pattern.compile("\\d*.?\\d*");
  /**
   * 手机号码Pattern
   */
  public static final Pattern MOBILE_NUMBER_PATTERN = Pattern
      .compile("\\d{11}");
  /**
   * 银行帐号Pattern
   */
  public static final Pattern ACCOUNT_NUMBER_PATTERN = Pattern
      .compile("\\d{16,21}");
  /**
   * 车牌号码是否正确
   *
   * @param s
   * @return
   */
  public static boolean isPlateNumber(String s) {
    Matcher m = PLATE_NUMBER_PATTERN.matcher(s);
    return m.matches();
  }
  /**
   * 证件号码是否正确
   *
   * @param s
   * @return
   */
  public static boolean isIDCode(String s) {
    Matcher m = ID_CODE_PATTERN.matcher(s);
    return m.matches();
  }
  /**
   * 编码是否正确
   *
   * @param s
   * @return
   */
  public static boolean isCode(String s) {
    Matcher m = CODE_PATTERN.matcher(s);
    return m.matches();
  }
  /**
   * 固话编码是否正确
   *
   * @param s
   * @return
   */
  public static boolean isPhoneNumber(String s) {
    Matcher m = PHONE_NUMBER_PATTERN.matcher(s);
    return m.matches();
  }
  /**
   * 邮政编码是否正确
   *
   * @param s
   * @return
   */
  public static boolean isPostCode(String s) {
    Matcher m = POST_CODE_PATTERN.matcher(s);
    return m.matches();
  }
  /**
   * 面积是否正确
   *
   * @param s
   * @return
   */
  public static boolean isArea(String s) {
    Matcher m = AREA_PATTERN.matcher(s);
    return m.matches();
  }
  /**
   * 手机号码否正确
   *
   * @param s
   * @return
   */
  public static boolean isMobileNumber(String s) {
    Matcher m = MOBILE_NUMBER_PATTERN.matcher(s);
    return m.matches();
  }
  /**
   * 银行账号否正确
   *
   * @param s
   * @return
   */
  public static boolean isAccountNumber(String s) {
    Matcher m = ACCOUNT_NUMBER_PATTERN.matcher(s);
    return m.matches();
  }
}

以上是“Android开发中正则表达式工具类RegexUtil的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


网站题目:Android开发中正则表达式工具类RegexUtil的示例分析
文章URL:http://bzwzjz.com/article/goihis.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 专业网站建设 成都网站建设公司 重庆手机网站建设 网站设计 成都网站设计 LED网站设计方案 网站建设方案 成都网站制作 成都网站建设 成都营销网站建设 外贸网站设计方案 重庆网站设计 成都企业网站建设公司 成都网站建设公司 移动网站建设 品牌网站建设 成都网站设计 网站制作 响应式网站设计方案 重庆企业网站建设 重庆网站建设 企业手机网站建设