子晴的编程日记

记录我的编程日记

导航

验证是否是数字

//using System.Text.RegularExpressions;

public static bool IsNumeric(string value)
{
return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
}
public static bool IsInt(string value)
{
return Regex.IsMatch(value, @"^[+-]?\d*$");
}
public static bool IsUnsign(string value)
{
return Regex.IsMatch(value, @"^\d*[.]?\d*$");
}

public static bool isTel(string strInput)
{
return Regex.IsMatch(strInput, @"\d{3}-\d{8}|\d{4}-\d{7}");
}

posted on 2019-08-22 11:22  子晴的编程日记  阅读(131)  评论(0编辑  收藏  举报