{"id":76,"date":"2014-11-17T06:48:23","date_gmt":"2014-11-17T06:48:23","guid":{"rendered":"https:\/\/www.kolkataonweb.com\/code-bank\/?p=76"},"modified":"2015-01-16T17:14:28","modified_gmt":"2015-01-16T17:14:28","slug":"some-useful-regex","status":"publish","type":"post","link":"https:\/\/www.kolkataonweb.com\/code-bank\/php\/some-useful-regex\/","title":{"rendered":"Some Useful Regex"},"content":{"rendered":"<p><strong>Mail-id verification:<\/strong><\/p>\n<pre class='wp-code-highlight prettyprint'>\/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$\/<\/pre>\n<p><em style=\"font-size: 14px;\">Though both can be used in PHP and JS but there is another method to verify an email-id in PHP, by using the below code<\/em><\/p>\n<pre class='wp-code-highlight prettyprint'><em style=\"font-size: 14px;\">if(!filter_var($email, FILTER_VALIDATE_EMAIL))<\/em><\/pre>\n<p><em style=\"font-size: 14px;\">FILTER_VALIDATE_EMAIL is a predefined filter in PHP.<\/em><br \/>\n<strong>Name Verification:<\/strong><\/p>\n<pre class='wp-code-highlight prettyprint'>\/^[A-Za-z .'-]+$\/<\/pre>\n<p><strong>Phone Verification:<\/strong><\/p>\n<pre class='wp-code-highlight prettyprint'>\/^[0-9 -]+$\/<\/pre>\n<p><strong>Removing all spaces:<\/strong><\/p>\n<pre class='wp-code-highlight prettyprint'>$pattern = '\/\\s+\/';\r\n$replace = \"\";\r\n$string = preg_replace($pattern,$replace,$string);<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mail-id verification: \/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$\/ Though both can be used in PHP and JS but there is another method to verify an email-id in PHP, by using the below code if(!filter_var($email, FILTER_VALIDATE_EMAIL)) FILTER_VALIDATE_EMAIL is a predefined filter in PHP. Name Verification: \/^[A-Za-z .&#8217;-]+$\/ Phone Verification: \/^[0-9 -]+$\/ Removing all spaces: $pattern = &#8216;\/\\s+\/&#8217;; $replace = &#8220;&#8221;; $string&hellip; <a class=\"more-link\" href=\"https:\/\/www.kolkataonweb.com\/code-bank\/php\/some-useful-regex\/\">Continue reading <span class=\"screen-reader-text\">Some Useful Regex<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-php","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":10,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":217,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/76\/revisions\/217"}],"wp:attachment":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}