正则表达式使用代码片段
/***校验是否为正的浮点数 */ public static bool IsFloat(string str) { Regex rx = new Regex(@"^[0-9]*(.)?[0-9]+$", RegexOptions.IgnoreCase); return rx.IsMatch(str.Trim()); }
/*** 检测串是否只含数字*/public static bool IsInt(string str) { Regex rx = new Regex(@"^[0123456789]+$"); return rx.IsMatch(str); }
/***检验字符串是否为电子邮件 */ public static bool IsEMail(string str) { Regex rx = new Regex(@"w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*"); return rx.IsMatch(str); }
TAG: