using System; using System.Text.RegularExpressions; namespace Test { class Program { //匹配16进制颜色代码的正则模式 const string pattern = @"\[[0-9a-fA-F]{6}\]"; const string test1 = "erter[0051e4]terter778t"; const string test2 = "erter[+051e4]terter778t"; static void Main(string[] args) { Regex res = new Regex(pattern); if (res.IsMatch(test1)) { Console.WriteLine("匹配成功"); } else { Console.WriteLine("匹配失败"); } Console.ReadKey(); } } }
C#中一个简单的匹配16进制颜色的正则测试
猜你喜欢
转载自www.cnblogs.com/luguoshuai/p/9150920.html
今日推荐
周排行