{"id":326,"date":"2011-09-11T06:49:51","date_gmt":"2011-09-11T01:49:51","guid":{"rendered":"http:\/\/kennywu.info\/?p=326"},"modified":"2011-09-11T06:49:51","modified_gmt":"2011-09-11T01:49:51","slug":"email-address-validation","status":"publish","type":"post","link":"http:\/\/kennywu.info\/?p=326","title":{"rendered":"Email address validation"},"content":{"rendered":"<p><code><br \/>\nusing System.Text.RegularExpressions;<\/p>\n<p>    public static class KWUExtensions {<br \/>\n        public static bool IsValidEmailAddress(this string s) {<br \/>\n            Regex regex = new Regex(@\"^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$\");<br \/>\n            return regex.IsMatch(s);<br \/>\n        }<br \/>\n    }<br \/>\n<\/code><br \/>\nTo use it:<br \/>\n<code>string email = \"kenny@yahoo.ca\";<br \/>\n            bool result = email.IsValidEmailAddress();<br \/>\n            Console.WriteLine(\"{0} is : {1}\", email, result);<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>using System.Text.RegularExpressions; public static class KWUExtensions { public static bool IsValidEmailAddress(this string s) { Regex regex = new Regex(@&#8221;^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$&#8221;); return regex.IsMatch(s); } } To use it: string email = &#8220;kenny@yahoo.ca&#8221;; bool result = email.IsValidEmailAddress(); Console.WriteLine(&#8220;{0} is : {1}&#8221;, email, result);<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[17,74],"class_list":["post-326","post","type-post","status-publish","format-standard","hentry","category-programing","tag-c","tag-regex"],"_links":{"self":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326"}],"version-history":[{"count":2,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions"}],"predecessor-version":[{"id":328,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions\/328"}],"wp:attachment":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}