zoukankan      html  css  js  c++  java
  • 较全的正则表达式

     

    // JScript source code
     2//整数
     3"int":"^([+-]?)\\d+$",
     4
     5//正整数
     6"int+":"^([+]?)\\d+$",                              
     7
     8//负整数
     9"int-":"^-\\d+$",                                   
    10
    11//数字
    12"num":"^([+-]?)\\d*\\.?\\d+$",                      
    13
    14//正数
    15"num+":"^([+]?)\\d*\\.?\\d+$"
    16
    17//负数
    18"num-":"^-\\d*\\.?\\d+$",                           
    19
    20//浮点数
    21"float":"^([+-]?)\\d*\\.\\d+$",                     
    22
    23//正浮点数
    24"float+":"^([+]?)\\d*\\.\\d+$",                     
    25
    26//负浮点数
    27"float-":"^-\\d*\\.\\d+$",                          
    28
    29//邮件
    30"email":"^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$",  
    31
    32//颜色
    33"color":"^#[a-fA-F0-9]{6}"     
    34
    35//联接
    36"url":"^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$", 
    37
    38//仅中文
    39"chinese":"^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$"
    40非中文:[^\u4E00-\u9FA5]
    41//仅ACSII字符
    42"ascii":"^[\\x00-\\xFF]+$"
    43
    44//邮编
    45"zipcode":"^\\d{6}$"                       
    46
    47//手机
    48"mobile":"^0{0,1}13[0-9]{9}$"
    49
    50//ip地址
    51"ip4":"^\(([0-1]\\d{0,2})|(2[0-5]{0,2}))\\.(([0-1]\\d{0,2})|(2[0-5]{0,2}))\\.(([0-1]\\d{0,2})|(2[0-5]{0,2}))\\.(([0-1]\\d{0,2})|(2[0-5]{0,2}))$",   
    52
    53//非空
    54"notempty":"^\\S+$"
    55
    56//图片
    57"picture":"(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$"
    58
    59//压缩文件
    60"rar":"(.*)\\.(rar|zip|7zip|tgz)$"
    61
    62//日期
    63"date":"^\\d{2,4}[\\/\\-]?((((0?[13578])|(1[02]))[\\/|\\-]?((0?[1-9]|[0-2][0-9])|(3[01])))|(((0?[469])|(11))[\\/|\\-]?((0?[1-9]|[0-2][0-9])|(30)))|(0?[2][\\/\\-]?(0?[1-9]|[0-2][0-9])))$",                 
    64
    65//时间
    66"time":"^(20|21|22|23|[01]\\d|\\d)(([:.][0-5]\\d){1,2})$"

    //校验邮政编码
    function isPostalCode(s)
    {
    //var patrn=/^[a-zA-Z0-9]{3,12}$/;
    var patrn=/^[a-zA-Z0-9 ]{3,12}$/;
    if (!patrn.exec(s)) return false
    return true
    }


    //校验普通电话、传真号码:可以"+"开头,除数字外,可含有"-"
    function isTel(s)
    {
    //var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?(\d){1,12})+$/;
    var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
    if (!patrn.exec(s)) return false
    return true
    }

    是否含有中文:return Regex.IsMatch(strValue, "[\u0100-\uffff]");

  • 相关阅读:
    DDD 领域驱动设计-谈谈 Repository、IUnitOfWork 和 IDbContext 的实践
    UVA10071 Back to High School Physics
    UVA10071 Back to High School Physics
    UVA10055 Hashmat the Brave Warrior
    UVA10055 Hashmat the Brave Warrior
    UVA458 The Decoder
    UVA458 The Decoder
    HDU2054 A == B ?
    HDU2054 A == B ?
    POJ3414 Pots
  • 原文地址:https://www.cnblogs.com/eugenewu0808/p/Regular.html
Copyright © 2011-2022 走看看