{"id":1071,"date":"2010-06-14T16:32:53","date_gmt":"2010-06-14T11:02:53","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1071"},"modified":"2016-12-19T15:19:22","modified_gmt":"2016-12-19T09:49:22","slug":"password-validation-with-certain-conditions","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/password-validation-with-certain-conditions\/","title":{"rendered":"Password validation with certain conditions"},"content":{"rendered":"<p>Hi Friends,<\/p>\n<p>I needed to validate password for certain conditions. As per the requirements, any valid must password must pass the following conditions:<\/p>\n<ol>\n<li>Minimum of  7 characters<\/li>\n<li>Must have numbers and letters<\/li>\n<li>Must have at least a one special characters- &#8220;!,@,#,$,%,&amp;,*,(,),+&#8221;<\/li>\n<\/ol>\n<p>I wrote the following method to meet the requirements:<\/p>\n<blockquote>\n<pre lang=\"groovy\">import java.util.regex.*\r\n\r\nboolean validatePassword(String password) {\r\n   def pattern = \/^.*(?=.{7,})(?=.*\\d)(?=.*[a-zA-Z])(?=.*[!@#$%*&+()]).*$\/\r\n    def matcher = password =~ pattern\r\n    return matcher.getCount() ? true : false\r\n}\r\n<\/pre>\n<blockquote><p>I couldn&#8217;t make the single regular expression to make it work, so used two. If somebody knows better way of doing it the please share.<\/p>\n<p>Thanks to Imran for helping me in writing the regular expression.<\/p>\n<p>Hope this helped!<br \/>\n~~Amit Jain~~<br \/>\namit@intelligrape.com<br \/>\nhttp:\/\/www.tothenew.com<\/p><\/blockquote>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Hi Friends, I needed to validate password for certain conditions. As per the requirements, any valid must password must pass the following conditions: Minimum of 7 characters Must have numbers and letters Must have at least a one special characters- &#8220;!,@,#,$,%,&amp;,*,(,),+&#8221; I wrote the following method to meet the requirements: import java.util.regex.* boolean validatePassword(String password) [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[7],"tags":[299,9],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1071"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1071"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1071\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}