6位数的16进制限制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace RegexDemo
{
class Program
{
static void Main(string[] args)
{
string i = "000000";
string m = "d";
Regex r = new Regex("^[0-9a-fA-F]{1,6}$");
Boolean iMatch;
ValidateNumber(i, r, out iMatch);
Boolean mMatch;
ValidateNumber(m,r,out mMatch);
Console.WriteLine(iMatch);
Console.WriteLine(mMatch);
Console.Read();
}
private static void ValidateNumber(string i, Regex r, out Boolean iMatch)
{
iMatch = r.IsMatch(i);
}
}
}