Code 1using System; 2using System.Collections.Generic; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Text; 7using System.Windows.Forms; 8//using System.Text.RegularExpressions; 9namespace Ex06_0110{11 public partial class Form1 : Form12 {13 public Form1()14 {15 InitializeComponent();16 }17 18 private void button1_Click(object sender, EventArgs e)19 {20 if (!IsEmail(textBox1.Text)) 21 MessageBox.Show("Email格式不合格"); 22 else 23 MessageBox.Show("Email格式合格"); 24 }25 public bool IsEmail(string str_Email)26 {27 return System.Text.RegularExpressions.Regex.IsMatch(str_Email, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");28 }29 }30} 转载于:https://www.cnblogs.com/shenzhenzsw/archive/2008/08/28/1278983.html