用正则表达式来判断是否有需要的字符串
2016-03-16 13:57
357 查看
/// <summary> /// 判断文本框中输入是否为【数字】 /// </summary> /// <param name="itemValue"></param> /// <returns></returns> private static bool IsNumeric(string itemValue) { return (IsRegEx("^(-?[0-9]*[.]*[0-9]{0,3})$", itemValue)); } /// <summary> /// 判断文本框中输入是否为【数字,字母】 /// </summary> /// <param name="str"></param> /// <returns></returns> public static bool IsNatural_Number(string str) { System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[A-Za-z0-9]+$"); return reg1.IsMatch(str); } private static bool IsRegEx(string regExValue, string itemValue) { try { Regex regex = new System.Text.RegularExpressions.Regex(regExValue); if (regex.IsMatch(itemValue)) return true; else return false; } catch (Exception) { return false; } }
相关文章推荐
- centos 6.5 安装docker
- 监听android home键的实现方式
- shell脚本获取日期的格式
- Oracle权限管理
- MySQL集群搭建详解
- SYN1621型 定位定向授时设备
- centos 6.5 安装docker
- 立体匹配:关于Middlebury提供的源码的简化后的结构
- gulp顺序执行任务
- sql语句的优化分析
- 状态同步与帧同步
- 你可能不知道的字符比较中的“秘密”
- 数组复制
- EL表达式截取字符串
- SYN1618型 高精度天文时间同步系统
- 多线程同步标记
- mode(思维,注意内存)
- uva 11151 Longest Palindrome
- Block的引用循环问题 (ARC & non-ARC)
- Python 断言assert的使用