實現效果:

知識運用:(下圖中好像多了個'(' )

實現代碼:
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}))$");
}
