码迷,mamicode.com
首页 > 其他好文 > 详细

正则表达式字符匹配

时间:2015-07-18 13:49:33      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZC.Common
{
    public class RegexPattern
    {
        //电话或手机号码
        public static string Phone = @"(^(\d{3,4})?-?\d{7,8}$)|(^1[0-9]{10}$)";
        //电话号码
        public static string Telephone = @"^(\d{3,4})?-?\d{7,8}$";
        //汉字
        public static string Cn = @"^[\u4e00-\u9fa5]{0,}$";
        //数字
        public static string Num = @"^[\d-]{0,}$";
        //包含汉字
        public static string CotainCn = @"[\u4e00-\u9fa5]";
        //密码
        public static string Password = @"^\w{6,18}$";
        //电子邮箱
        public static string Email = @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
        //Qq
        public static string Qq = @"^([1-9][0-9]{4})|([0-9]{6,10})$";
        //网址
        public static string Url = @"^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$";
        //车牌号
        public static string CarNumber = @"^[\u4e00-\u9fa5][A-Z]-?[A-Z0-9]{5}$";
        //身份证号码
        public static string IdCard = @"^(\d{14}|\d{17})(\d|[xX])$";
        //Ip地址
        public static string Ip = @"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]).(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]).(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]).(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$";
        //手机号码
        public static string Mobile = @"^1[0-9]{10}$";
        //中文姓名
        public static string CnName = @"[\u3000-\u9FA5\x20]{2,8}";
        //英文姓名
        public static string EnName = @"[a-zA-Z][\w\-]{2,17}";
        //用户昵称
        public static string NickName = @"[\u3000-\u9FA5a-zA-Z][\u3000-\u9FA5\w\-]{1,17}";
        //金额
        public static string Money = @"\d+[\.]?\d{0,2}";
        //日期
        public static string Date = @"^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-9]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$";
        
        //时间
        public static string Time = @"^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$";
 
        //邮编
        public static string PostalCode = @"^[1-9]\d{5}$";
        //年龄
        public static string Age = @"1[0-2]\d|\d{1,2}";
        //图片地址
        public static string ImageUrl ="src[^>]*[^/].(?:jpg|bmp|gif)(?:\"|\‘)";
        //下列请选择
        public static string PleaseSelect = @"请选择";
    }
}

正则表达式字符匹配

标签:

原文地址:http://www.cnblogs.com/huangdegen/p/4656662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!