Skip to content

Instantly share code, notes, and snippets.

Created February 12, 2012 18:07
Show Gist options
  • Save anonymous/1809961 to your computer and use it in GitHub Desktop.
Save anonymous/1809961 to your computer and use it in GitHub Desktop.
using System;
using System.Text.RegularExpressions;
class User
{
int _id;
string _login;
string _password;
string _email;
public string Email
{
set
{
string pat = @" ^(?("")("".+?""@)|
(([0-9a-zA-Z]((\.(?!\.))
|[-!#\$%&'\*\+/=\?\^`\{\}\|
~\w])*)(?<=[0-9a-zA-Z])@))
(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|
(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)
+[a-zA-Z]{2,6}))$"; // regexp mak
if (!(new Regex(pat)).IsMatch(value))
throw new ArgumentOutOfRangeException("Email");
_email = value;
}
get
{
return _email;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment