asp.net中使用正则表达式

it2022-05-05  148

1.重写IsRegEx方法:

 private bool IsRegEx(string regEx, string value){ try {  Regex regex = new Regex(regEx);  if (regex.IsMatch(value))   return true;  else return false; } catch (System.Exception) {  return false; } finally { }}

 

2.调用重写后的方法执行判断:

private bool isCorrectString(string value){ return (IsRegEx("^[0-9]\\S*[a-zA-Z]\\S*",value));}

转载于:https://www.cnblogs.com/Believe/archive/2010/02/11/1667517.html


最新回复(0)