⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 a compiler in java that parses and creates lexer analyzer
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace RegexFinder
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = "";
            string filename = textBox1.Text;
            if (File.Exists(filename))
            {
                try
                {
                    StreamReader stream = new StreamReader(filename);
                    textBox2.Text += stream.ReadToEnd();
                }
                catch (IOException)
                {
                    MessageBox.Show("File Error", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string output = "";
            output += "\n\tFollowing Strings Were Matched:\n\n";
            if (textBox2.Text == "")
            {
                MessageBox.Show("Please Load A Valid File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else 
            {
                Regex expression = new Regex("\\d{3}-\\d{3}-\\d{4}");
                string st1 = textBox2.Text;
                foreach (Match myMatch in expression.Matches(st1))
                {
                    output += "\t"+ myMatch.ToString() + "\n";
                }
                MessageBox.Show(output, "Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
                
            }
        }

       
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -