using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Reflection.Emit;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
using System.Threading.Tasks;
|
|
namespace XCommon.Check.Data
|
{
|
public class ValidateData
|
{
|
private static Regex RegNumber = new Regex("^[0-9]+$");
|
private static Regex RegDecimal = new Regex("^[0-9]+[.]?[0-9]+$");
|
private static Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$");
|
|
|
|
|
/// <summary>
|
/// 是否为ip
|
/// </summary>
|
/// <param name="inputData"></param>
|
/// <returns></returns>
|
public static bool IsIp(string inputData)
|
{
|
return Regex.IsMatch(inputData, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
|
}
|
|
|
#region 数字字符串检查
|
/// <summary>
|
/// 是否为数字
|
/// </summary>
|
/// <param name="inputData"& gt;输入字符串</param>
|
/// <returns></returns>
|
public static bool IsNumber(string inputData)
|
{
|
Match m = RegNumber.Match(inputData);
|
return m.Success;
|
}
|
|
/// <summary>
|
/// 是否是浮点数
|
/// </summary>
|
/// <param name="inputData"& gt;输入字符串</param>
|
/// <returns></returns>
|
public static bool IsDecimal(string inputData)
|
{
|
Match m = RegDecimal.Match(inputData);
|
return m.Success;
|
}
|
#endregion
|
|
#region 邮件地址
|
/// <summary>
|
/// 是否是浮点数 可带正负号
|
/// </summary>
|
/// <param name="inputData"& gt;输入字符串</param>
|
/// <returns></returns>
|
public static bool IsEmail(string inputData)
|
{
|
Match m = RegEmail.Match(inputData);
|
return m.Success;
|
}
|
#endregion
|
|
|
}
|
}
|