using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace XCommon.Check.Data { public class ValidateData { private static Regex RegNumber = new Regex("^[0-9]+$"); private static Regex RegDecimal = new Regex("^[0-9]+[.]?[0-9]+$"); private static Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$"); /// /// 是否为ip /// /// /// public static bool IsIp(string inputData) { return Regex.IsMatch(inputData, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"); } #region 数字字符串检查 /// /// 是否为数字 /// /// /// public static bool IsNumber(string inputData) { Match m = RegNumber.Match(inputData); return m.Success; } /// /// 是否是浮点数 /// /// /// public static bool IsDecimal(string inputData) { Match m = RegDecimal.Match(inputData); return m.Success; } #endregion #region 邮件地址 /// /// 是否是浮点数 可带正负号 /// /// /// public static bool IsEmail(string inputData) { Match m = RegEmail.Match(inputData); return m.Success; } #endregion } }