public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- string input = textBox1.Text.Trim();
- if (chkInput(input))
- MessageBox.Show("true");
- else
- MessageBox.Show("false");
- }
-
-
-
-
-
- private bool chkInput(string input)
- {
- Regex regex = new Regex(@"^[\u4E00-\u9FFFA-Za-z0-9]+$");
- return regex.IsMatch(input);
- }
- }
如果输入的不是英文字母或者数字或者汉字,则返回false
原文:http://www.cnblogs.com/DTWolf/p/4660802.html