[csharp]
private static Regex RegPhone = new Regex("^[0-9]+[-]?[0-9]+[-]?[0-9]{1}$");
private static Regex RegNumber = new Regex("^[0-9]+{1}$");
private static Regex RegNumberSign = new Regex("^[+-]?[0-9]+{1}$");
private static Regex RegDecimal = new Regex("^[0-9]+[.]?[0-9]+{1}$");
private static Regex RegDecimalSign = new Regex("^[+-]?[0-9]+[.]?[0-9]+{1}$"); //等價於^[+-]?\d+[.]?\d+$
private static Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info){1}$");//w 英文字母或數字的字符串,和 [a-zA-Z0-9] 語法一樣
private static Regex RegCHZN = new Regex("[\u4e00-\u9fa5]");//是否有中文
一個例子:
[csharp]
#region 中文檢測
/// <summary>
/// 檢測是否有中文字符
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public static bool IsHasCHZN(string inputData)
{
Match m = RegCHZN.Match(inputData);
return m.Success;
}
#endregion