You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
5.7 KiB
195 lines
5.7 KiB
1 month ago
|
using System;
|
||
|
using System.Text.RegularExpressions;
|
||
|
|
||
|
namespace SiaSun.LMS.Common
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// RegexValid ��������ʽƥ����
|
||
|
/// </summary>
|
||
|
public class RegexValid
|
||
|
{
|
||
|
#region ------ƥ�������ַ���
|
||
|
/// <summary>
|
||
|
/// ��֤Email��ʽ
|
||
|
/// </summary>
|
||
|
static public string Email = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤��������
|
||
|
/// </summary>
|
||
|
static public string Brith = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤URL
|
||
|
/// </summary>
|
||
|
static public string URL = @"^\s*(\d{4})-(\d{2})-(\d{2})\s*$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤�û�����
|
||
|
/// </summary>
|
||
|
static public string Pwd = @"^[a-zA-Z]\w{5,17}$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ�����뺺��
|
||
|
/// </summary>
|
||
|
static public string Chinese = @"^[\u4e00-\u9fa5]{0,}$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤�Ƿ�Ϊ����
|
||
|
/// </summary>
|
||
|
static public string Integer = @"^[0-9]*$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ������������������
|
||
|
/// </summary>
|
||
|
static public string Positive = @"^\+?[1-9][0-9]*$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ�������� 26 ��Ӣ����ĸ���ɵ��ַ���
|
||
|
/// </summary>
|
||
|
static public string LetterStr = @"^[A-Za-z]+$";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ�����������ֺ� 26 ��Ӣ����ĸ���ɵ��ַ���
|
||
|
/// </summary>
|
||
|
static public string NumLetterStr = @"^[A-Za-z0-9]+$";
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region --------����Ӧ��
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤Email��ʽ
|
||
|
/// </summary>
|
||
|
/// <param name="strEmail">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidEmai(string strEmail)
|
||
|
{
|
||
|
return Regex.IsMatch(strEmail, Email);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤��������
|
||
|
/// </summary>
|
||
|
/// <param name="strBirth">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidBirth(string strBirth)
|
||
|
{
|
||
|
return Regex.IsMatch(strBirth, Brith);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤URL
|
||
|
/// </summary>
|
||
|
/// <param name="strURL">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidURL(string strURL)
|
||
|
{
|
||
|
return Regex.IsMatch(strURL,URL);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��֤�û�����,����ĸ��ͷ��������6��18֮�䣬ֻ�ܰ����ַ������ֺ��»���
|
||
|
/// </summary>
|
||
|
/// <param name="str1">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidPassword(string str1)
|
||
|
{
|
||
|
return Regex.IsMatch(str1, Pwd);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ�����뺺��
|
||
|
/// </summary>
|
||
|
/// <param name="str1">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidChinese(string str1)
|
||
|
{
|
||
|
return Regex.IsMatch(str1, Chinese);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region -----������֤
|
||
|
/// <summary>
|
||
|
/// ��֤�Ƿ�Ϊ����
|
||
|
/// </summary>
|
||
|
/// <param name="str1">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidInteger(string str1)
|
||
|
{
|
||
|
return Regex.IsMatch(str1,Integer );
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ������������������
|
||
|
/// </summary>
|
||
|
/// <param name="str1">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidPositive(string str1)
|
||
|
{
|
||
|
return Regex.IsMatch(str1, Positive);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region -------�ַ�����֤
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ�������� 26 ��Ӣ����ĸ���ɵ��ַ���
|
||
|
/// </summary>
|
||
|
/// <param name="str1">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidLetterStr(string str1)
|
||
|
{
|
||
|
return Regex.IsMatch(str1, LetterStr);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ֻ�����������ֺ� 26 ��Ӣ����ĸ���ɵ��ַ���
|
||
|
/// </summary>
|
||
|
/// <param name="str1">��֤�ַ���</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool IsValidNumLetterStr(string str1)
|
||
|
{
|
||
|
return Regex.IsMatch(str1, NumLetterStr);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ʹ����������ʽ��֤�ַ���
|
||
|
/// </summary>
|
||
|
/// <param name="strCode">����֤�ַ���</param>
|
||
|
/// <param name="strAppItem">�����ļ�����������ʽ��ID</param>
|
||
|
/// <returns>�Ϸ�����true,����false</returns>
|
||
|
public static bool GetCodeCheck(string strCode, string strAppItem)
|
||
|
{
|
||
|
string strCheck = SiaSun.LMS.Common.StringUtil.GetConfig(strAppItem);
|
||
|
Match mCode = Regex.Match(strCode, strCheck);
|
||
|
if (mCode.Success)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
/// <summary>
|
||
|
/// �ж��ı��Ƿ�����ƥ��ģʽ
|
||
|
/// </summary>
|
||
|
public static bool IsValidate(string Text,string MatchModel)
|
||
|
{
|
||
|
return Regex.IsMatch(Text, MatchModel);
|
||
|
}
|
||
|
|
||
|
public static bool GoodsBarcodeValidate(string sGoodsBarcode)
|
||
|
{
|
||
|
return Regex.IsMatch(sGoodsBarcode, "^[A-Z|0-9]+-[A-Z|0-9]+-[A-Z|0-9]+-[A-Z|0-9]+-[A-Z|0-9]+-[A-Z|0-9]+-[0-9|.]+-KG$");
|
||
|
//return Regex.IsMatch(sGoodsBarcode, "^[A-Z]{1,2}[0-9]{2}-[A-Z][0-9]{2}-[0-9]{4}-[A-Z]{2}[0-9]?-[0-9]{3}-[0-9]+-[0-9|.]+-KG$");
|
||
|
}
|
||
|
}
|
||
|
}
|