1.引用名稱空間
using System.Text.RegularExpressions;
2.代碼:
string strInput="
[email protected]";
string strExp=@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
// Create a new Regex object.
Regex r = new Regex(strExp);
// Find a single match in the string.
Match m = r.Match(strInput);
if (m.Success)
{
MessageBox.Show("驗證成功!");
}