public static bool IsNumNotMinus(string str)
{
bool isMatch = IsMatchRegular(str, @"^[0]*([.]\d+)$");
if (isMatch == false)
{
bool isMatch1 = IsMatchRegular(str, @"^[1-9][0-9]*([.]\d+)?$");
if (isMatch1 == true)
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
以上驗證的是大於0的數,如果包括0, bool isMatch = IsMatchRegular(str, @"^[0]*([.]\d+)$");改爲
bool isMatch = IsMatchRegular(str, @"^[0]*([.]\d+)?$");就行了