正則表達式 匹配郵箱

   public void Regular_Expression()
        {
            WebClient wc = new WebClient(); //
            wc.Encoding = Encoding.Default;
          string str = wc.DownloadString("http://localhost:32768/想要上Facebook,twitter的童鞋報道,留下你的Email%20且聽風吟%20電影.htm");//下載HTml文檔
          // 365169098@qq.com
             string regular = @"\w[a-zA-z0-9\-\._]+@[a-zA-z0-9\-_]+(\.[a-zA-Z0-9]+)+";
            MatchCollection  machs =System.Text.RegularExpressions.Regex.Matches(str,regular);
            
          int i = 0;
          List<string> lsit = new List<string>();
          foreach (Match s in machs)
            {
                if (!lsit.Contains(s.Value))
                {
                    lsit.Add(s.Value);
                    Console.WriteLine(i++ + "  " + s.Value);
                }
             //   Console.WriteLine(i++ +"  "+s.Value);
            }

        }
相關文章
相關標籤/搜索