IsValidEmailAddress
public static class ScottGuExtensions { public static bool IsValidEmailAddress(this string s) { Regex regex = new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"); return regex.IsMatch(s); } }Example:
bool f = "test@test.com".IsValidEmailAddress();
Description
Check wheter a string is an valid e-mail address
Details
- Author: Scott Guthrie
- Submitted on: 21-8-2007 11:46:39
- Language: C#
- Type: System.String
- Views: 8282
Double click on the code to select all.