using System;
using System.Text.RegularExpressions;
namespace Sp.Common
{
public class ValidatorHelper
{
/// <summary>
/// 验证数字长度范围(数字前端的0计长度)
/// [若要验证固定长度,可传入相同的两个长度数值]
/// </summary>
/// <param name="input">待验证的字符串</param>
/// <param name="lengthBegin">长度范围起始值(含)</param>
/// <param name="lengthEnd">长度范围结束值(含)</param>
/// <returns>是否匹配</returns>
public static bool IsIntegerLength(string input, int lengthBegin, int lengthEnd)
{
//string pattern = @"^d{" + lengthBegin + "," + lengthEnd + "}$";
//return IsMatch(input, pattern);
if (input.Length >= lengthBegin && input.Length <= lengthEnd)
{
int i;
if (int.TryParse(input, out i))
return true;
else
return false;
}
else
return false;
}
}
}