{"id":25,"date":"2025-06-18T13:39:15","date_gmt":"2025-06-18T13:39:15","guid":{"rendered":"https:\/\/davidlindon.com\/?p=25"},"modified":"2025-06-18T13:39:15","modified_gmt":"2025-06-18T13:39:15","slug":"complex-password-validation-regular-expression","status":"publish","type":"post","link":"https:\/\/davidlindon.com\/?p=25","title":{"rendered":"Complex password validation regular expression"},"content":{"rendered":"\n<p>I needed a regular expression to validate the following<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>12 characters<\/li>\n\n\n\n<li>1 number<\/li>\n\n\n\n<li>1 special character<\/li>\n<\/ul>\n\n\n\n<p>To check for a &#8216;special character&#8217;, my first attempt created an extremely long regex  with all the various possible characters. This become unmanagable so I decided to opt for ranges of ASCII characters. The resulting regex is<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>^(?=.*?(&#91;A-Z]|&#91;a-z]))(?=.*?&#91;0-9])(?=.*?(&#91;\\x20-\\x2F]|&#91;\\x3A-\\x40]|&#91;\\x5B-\\x60]|&#91;\\x7B-\\xFF])).{12,}$<\/code><\/pre>\n\n\n\n<p>When we break this down, the first group looks for a letter character, the second looks for a number and the third looks for our special characters. Obviously then we ensure a minimum length of 12 characters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed a regular expression to validate the following To check for a &#8216;special character&#8217;, my first attempt created an extremely long regex with all the various possible characters. This become unmanagable so I decided to opt for ranges of ASCII characters. The resulting regex is When we break this down, the first group looks [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-25","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/davidlindon.com\/index.php?rest_route=\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davidlindon.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davidlindon.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davidlindon.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davidlindon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":1,"href":"https:\/\/davidlindon.com\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":26,"href":"https:\/\/davidlindon.com\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions\/26"}],"wp:attachment":[{"href":"https:\/\/davidlindon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davidlindon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davidlindon.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}