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));
}