最近再学习一下正则表达式 写了个小工具自己测试

好久没写Form 代码了,手都有点痒了..

写了个正则表达式测试软件

代码很少命名规范这些 就忽略了哈...呵呵

1 private void textBox2_TextChanged(object sender, EventArgs e)
2 {
3 if (textBox2.Text != "" && textBox1.Text!="")
4 {
5 if (checkBox1.Checked)
6 {
7 textBox3.Text = "";
8 }
9 try
10 {
11 MatchCollection c = Regex.Matches(textBox2.Text, textBox1.Text);
12 foreach (Match item in c)
13 {
14 textBox3.Text = textBox3.Text + item.Value + "\r\n";
15 }
16 }
17 catch (Exception ex)
18 {
19 textBox3.Text = textBox3.Text + ex.Message + "\r\n";
20 }
21 textBox3.SelectionStart = textBox3.Text.Length; //使滚动条在最下
22 textBox3.ScrollToCaret();
23 }
24 }
25
26 private void button1_Click(object sender, EventArgs e)
27 {
28 textBox3.Text = "";
29 }

源码见附件!

https://files.cnblogs.com/gaoshan/form3.rar

posted @ 2011-04-07 17:13  跨越高山  阅读(263)  评论(0)    收藏  举报