判断是否数字的正则表达式
By:Roy.LiuLast updated:2008-11-24
static public bool IsNumeric(object number)
{
if(IsObjectEmpty(number)) return false;
System.Text.RegularExpressions.Regex rCode = new System.Text.RegularExpressions.Regex(@"^[-+]?\d+(\.\d+)?$");
return (rCode.IsMatch(number.ToString()));
}
//判断一个对象是不是空
public static bool IsObjectEmpty(object oo)
{
if (oo == null || oo is System.DBNull)
{
return true;
}
if (oo is string)
{
if (oo.ToString() == "") return (true);
}
return (false);
}
{
if(IsObjectEmpty(number)) return false;
System.Text.RegularExpressions.Regex rCode = new System.Text.RegularExpressions.Regex(@"^[-+]?\d+(\.\d+)?$");
return (rCode.IsMatch(number.ToString()));
}
//判断一个对象是不是空
public static bool IsObjectEmpty(object oo)
{
if (oo == null || oo is System.DBNull)
{
return true;
}
if (oo is string)
{
if (oo.ToString() == "") return (true);
}
return (false);
}
From:一号门
Previous:越狱
COMMENTS