📄 formregexvalidation.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace RegexExample1
{
public partial class FormRegexValidation : Form
{
public FormRegexValidation()
{
InitializeComponent();
}
private void buttonValidation_Click(object sender, EventArgs e)
{
//System.Text.RegularExpressions.Regex r =
// new System.Text.RegularExpressions.Regex(textBoxValidateString.Text);
//if (r.IsMatch(textBoxValidatedString.Text) == true)
//{
// textBoxIsMatch.Text = "有匹配项";
//}
//else
//{
// textBoxIsMatch.Text = "没有匹配项";
//}
System.Text.RegularExpressions.Regex r =
new System.Text.RegularExpressions.Regex(textBoxValidateString.Text);
if (r.IsMatch(textBoxValidatedString.Text) == true)
{
textBoxIsMatch.Text = "有匹配项";
}
else
{
textBoxIsMatch.Text = "没有匹配项";
}
}
private void textBoxValidatedString_Enter(object sender, EventArgs e)
{
textBoxIsMatch.Clear();
}
private void textBoxValidateString_Enter(object sender, EventArgs e)
{
textBoxIsMatch.Clear();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -