标签:
namespace WindowsFormsApplication5 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { WebClient wc = new WebClient();//定义一个新的 wc.Encoding = Encoding.Default;//定义他的格式,防止除乱码 string url = textBox1.Text.Trim();//定义一个接收文本一的内容 //if (string.IsNullOrEmpty(url)) //{ // return; //} string html = wc.DownloadString(url); MatchCollection mc = Regex.Matches(html, @"[a-zA-Z0-9_\-\.]+@\w+(\.\w+)+");//邮箱的正则表达式 StringBuilder sb = new StringBuilder(); foreach (Match m in mc) { sb.AppendLine(m.Value); } textBox2.Text = sb.ToString(); //File.WriteAllText(@"E:\1.txt", sb.ToString()); StreamWriter sw = new StreamWriter(@"E:\1.txt",true); sw.WriteLine(sb.ToString()); } private void Form1_Load(object sender, EventArgs e) { } }
标签:
原文地址:http://www.cnblogs.com/w-wz/p/4611441.html