正则表达式

1,字符串的提取

         a.先创建好符合规则的正则表达式

         b.将部分用()包含

         string str = "192.168.10.5[port=21,type=ftp]";

         Match macth = Regex.Match(str, @"^(.+)[[].+=(\d{2}),.+=(.+)[]]$");

         if (macth.Success)

            {

                Console.WriteLine(macth.Groups[1]);

                Console.WriteLine(macth.Groups[2]);

                Console.WriteLine(macth.Groups[2]);       

           }

 

邮箱:[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z].{2,4}

posted @ 2015-03-12 10:12  10:00  阅读(154)  评论(0)    收藏  举报