• 常用正则表达式


    /// <summary>
    /// 身份证
    /// </summary>
    public static readonly string IDCard = @"^(^[1-9]d{7}((0d)|(1[0-2]))(([0|1|2]d)|3[0-1])d{3}$)|(^[1-9]d{5}[1-9]d{3}((0d)|(1[0-2]))(([0|1|2]d)|3[0-1])((d{4})|d{3}[Xx])$)$";

    /// <summary>
    /// 港澳通行证
    /// </summary>
    public static readonly string PassCard = @"^[HMhm]{1}([0-9]{10}|[0-9]{8})$";

    /// <summary>
    /// 护照
    /// </summary>
    public static readonly string Passport = @"^[a-zA-Z0-9]{5,17}$";

    /// <summary>
    /// 台胞证
    /// </summary>
    public static readonly string Taiwan =@"(^[0-9]{8}$)|(^[0-9]{10}$)";

    /// <summary>
    /// 手机号
    /// </summary>
    public static readonly string Mobile = @"^1d{10}$";

    /// <summary>
    /// 航空公司二字码
    /// </summary>
    public static readonly string AirlineCode = @"^[1-9a-zA-Z]{2}$";

    /// <summary>
    /// 舱位码
    /// </summary>
    public static readonly string SeatCode = @"^[A-Z]{1}([0-9]{1})?(\,[A-Z]{1}([0-9]{1})?)*$";

    /// <summary>
    /// 机场三字码或城市三字码
    /// </summary>
    public static readonly string CityCode = @"^[a-zA-Z]{3}$";

    /// <summary>
    /// 只能为数字或字符串
    /// </summary>
    public static readonly string NumberOrLetter = @"^[A-Za-z0-9]+$";

    /// <summary>
    /// 验证日期格式 yyyy-MM-dd
    /// </summary>
    public static readonly string Date = @"^d{4}-d{2}-d{2}$";

    /// <summary>
    /// 只匹配0和1
    /// </summary>
    public static readonly string OnlyZeroOrOne = @"^[0-1]{1}$";

  • 相关阅读:
    java 基础笔记 基本数据类型对象包装类
    java String 类 基础笔记
    java 线程 笔记 基础
    java 线程 基础笔记2
    java 异常学习 笔记
    广告简单概念整理-持续更新
    curl一些使用技巧
    简单学习正则表达式
    Linux命令简单操作之lsof
    Linux命令简单操作之find和xargs
  • 原文地址:https://www.cnblogs.com/taomylife/p/5165429.html
Copyright © 2020-2023  润新知