- /// <summary>
- /// 快速验证一个字符串是否符合指定的正则表达式。
- /// </summary>
- /// <param name="_express">正则表达式的内容。</param>
- /// <param name="_value">需验证的字符串。</param>
- /// <returns>是否合法的bool值。</returns>
- public static bool QuickValidate(string _express, string _value)
- {
- if (_value == null) return false;
- Regex myRegex = new Regex(_express);
- if (_value.Length == 0)
- {
- return false;
- }
- return myRegex.IsMatch(_value);
- }
- //该片段来自于http://www.codesnippet.cn/detail/220920136034.html
来源: http://www.codesnippet.cn/detail/220920136034.html