您好,欢迎光临本网站![请登录][注册会员]  
文件名称: C#制作简单正则表达式测试器
  所属分类: .Net
  开发工具:
  文件大小: 63kb
  下载次数: 0
  上传时间: 2011-10-16
  提 供 者: ys***
 详细说明: C#制作简单正则表达式测试器部分代码: namespace RegexTest { public partial class Rt : Form { public Rt() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; } private void btnPi_Click(object sender, EventArgs e) { if (regText.Text.Trim() != "") { ParameterizedThreadStart ts = new ParameterizedThreadStart(P); Thread th = new Thread(ts); th.Start(th); this.btnPi.Enab led = false; this.process.Visible = true; } else { ParameterizedThreadStart ts = new ParameterizedThreadStart(ShowMsg); Thread th = new Thread(ts); th.Start(th); } } public void ShowMsg(Object obj) { Thread th = (Thread)obj; for (var i = 0; i < 10; i++) { if (i % 2 == 0) { label2.ForeColor = Color.Red; } else { label2.ForeColor = Color.Black; } Thread.Sleep(100); } label2.ForeColor = Color.Red; th.Abort(); } public void P(object o) { Thread t = (Thread)o; resultText.Clear(); String regText = this.regText.Text; String sourceText = this.sourceText.Text; Regex regex = new Regex(regText, RegexOptions.IgnoreCase); MatchCollection matches = regex.Matches(sourceText); this.resultText.Text += "匹配结果数:" + matches.Count + "\n"; this.resultText.Text += "-----------------------------------------------------\n"; foreach (Match match in matches) { this.resultText.Text += "匹配值:" + match.Value + "\n"; this.resultText.Text += "匹配组结果:\n"; foreach (String g in regex.GetGroupNames()) { this.resultText.Text += "组(" + g + "):" + match.Groups[g].Value + "\n"; } resultText.Text += "-----------------------------------------------------\n"; } this.process.Visible = false; this.btnPi.Enabled = true; t.Abort(); } private void btnReplace_Click(object sender, EventArgs e) { resultText.Clear(); String regText = this.regText.Text; String replaceText = this.replaceText.Text; String sourceText = this.sourceText.Text; Regex regex = new Regex(regText); this.resultText.Text += "替换结果:\n"; this.resultText.Text += "-----------------------------------------------------\n"; this.resultText.Text += regex.Replace(sourceText,replaceText); } private void 复制ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.sourceText.SelectedText.Length > 0) { Clipboard.SetText(this.sourceText.SelectedText); MessageBox.Show("已成功将选中文本复制到剪切板"); } else { Clipboard.SetText(this.sourceText.Text); MessageBox.Show("已成功将文本复制到剪切板"); } } private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e) { this.sourceText.Paste(DataFormats.GetFormat("text")); } private void 清空ToolStripMenuItem_Click(object sender, EventArgs e) { this.sourceText.Clear(); } private void toolStripMenuItem1_Click(object sender, EventArgs e) { if (resultText.SelectedText.Length > 0) { Clipboard.SetText(this.resultText.SelectedText); MessageBox.Show("已成功将选中文本复制到剪切板"); } else { Clipboard.SetText(this.resultText.Text); MessageBox.Show("已成功将结果复制到剪切板"); } } private void toolStripMenuItem3_Click(object sender, EventArgs e) { this.resultText.Clear(); } private void Form1_Load(object sender, EventArgs e) { } private void resultText_TextChanged(object sender, EventArgs e) { //this.resultText. } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: