1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace CP.Common
- {
- public class Validator
- {
- /// <summary>
- /// 手机号码判断
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- public static bool IsPhone(string str)
- {
- string s = @"^(13[0-9]|15[0-9]|18[0-9]|14[0-9]|17[0-9]|16[0-9])\d{8}$";
- if (Regex.IsMatch(str, s))
- return true;
- return false;
- }
- /// <summary>
- /// 验证邮箱
- /// </summary>
- /// <param name="strEmail"></param>
- /// <returns></returns>
- public static bool IsValidEmail(string strEmail)
- {
- return Regex.IsMatch(strEmail, @"^[\w\.]+([-]\w+)*@[A-Za-z0-9-_]+[\.][A-Za-z0-9-_]");
- }
- /// <summary>
- /// 是否是数字
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- public static bool IsValidNumber(string str)
- {
- return Regex.IsMatch(str, @"^(\d+)");
- }
- }
- }
|