实现效果:
知识运用:(下图中好像多了个'(' )
实现代码:
private void button1_Click(object sender, EventArgs e) { if (validate(textBox1.Text)) textBox1.BackColor = Color.Green; else textBox1.BackColor = Color.Red; } public bool validate(string str_email) { return System.Text.RegularExpressions.Regex. IsMatch(textBox1.Text, @"^(([w.]+)@([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|((w+.?)+)@([a-zA-Z]{2,4}|[0-9]{1,3})(.[a-zA-Z]{2,4}))$"); }