public static bool checkString(string svalue)
{
if (Regex.IsMatch(svalue, @"^([0-9]{1,})(.*)([0-9]{1,})$"))
{
//如果表达式头尾是数字
//在检查是否匹配运算符是不是加减乘除,如果不是返回真
if (Regex.IsMatch(svalue, @"(([0-9]{1,})([\+\-\*\/]{2,})([0-9]{1,}))|(([0-9]{1,})([^\+\-\*\/]{1,})([0-9]{1,}))"))
{
//表示表达式不合法
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}