{"id":2294,"date":"2026-07-20T12:43:14","date_gmt":"2026-07-20T10:43:14","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/regular-expressions-tutorials\/"},"modified":"2026-08-27T17:29:28","modified_gmt":"2026-08-27T15:29:28","slug":"regular-expressions-tutorials","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/regular-expressions-tutorials\/","title":{"rendered":"Regular Expressions Tutorials"},"content":{"rendered":"<p><!-- ktg-updated-banner --><\/p>\n<p><em>Updated August 2026 \u2014 full tutorial restored for this URL.<\/em><\/p>\n<p>This <strong>regular expressions<\/strong> tutorial is a practical cheat sheet: metacharacters, groups, and examples you can paste into JavaScript or Python.<\/p>\n<ol>\n<li><a href=\"#t1\">Literals and character classes<\/a><\/li>\n<li><a href=\"#t2\">Quantifiers and anchors<\/a><\/li>\n<li><a href=\"#t3\">Groups and alternation<\/a><\/li>\n<li><a href=\"#t4\">Common recipes<\/a><\/li>\n<li><a href=\"#t5\">Test in JS and Python<\/a><\/li>\n<\/ol>\n<p><strong id=\"t1\">1. Literals and character classes<\/strong><\/p>\n<ul>\n<li><code>.<\/code> any char (except newline unless flag)<\/li>\n<li><code>\\d<\/code> digit, <code>\\w<\/code> word, <code>\\s<\/code> whitespace<\/li>\n<li><code>[abc]<\/code> one of, <code>[^abc]<\/code> none of, <code>[a-z]<\/code> range<\/li>\n<\/ul>\n<p><strong id=\"t2\">2. Quantifiers and anchors<\/strong><\/p>\n<ul>\n<li><code>*<\/code> 0+, <code>+<\/code> 1+, <code>?<\/code> 0 or 1, <code>{2,5}<\/code> range<\/li>\n<li><code>^<\/code> start, <code>$<\/code> end, <code>\\b<\/code> word boundary<\/li>\n<li>Prefer non-greedy <code>*?<\/code> \/ <code>+?<\/code> when matching HTML-ish snippets<\/li>\n<\/ul>\n<p><strong id=\"t3\">3. Groups and alternation<\/strong><\/p>\n<pre><code>(\\d{3})-(\\d{2})   # capturing groups\n(?:https?)         # non-capturing\ncat|dog            # alternation\n<\/code><\/pre>\n<p><strong id=\"t4\">4. Common recipes<\/strong><\/p>\n<pre><code>^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$     # simple email (demo only)\n^\\+?[0-9\\-\\s]{7,15}$            # rough phone\nhttps?:\/\/[^\\s]+                  # URLs in text\n<\/code><\/pre>\n<p><strong id=\"t5\">5. Test in JS and Python<\/strong><\/p>\n<pre><code>\/\/ JavaScript\nconst re = \/^\\d{4}-\\d{2}-\\d{2}$\/;\nconsole.log(re.test(\"2026-08-26\"));\n\n# Python\nimport re\nprint(bool(re.fullmatch(r\"\\d{4}-\\d{2}-\\d{2}\", \"2026-08-26\")))\n<\/code><\/pre>\n<p>Always write unit tests for regex used in validation \u2014 one wrong <code>.<\/code> can open security holes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updated August 2026 \u2014 full tutorial restored for this URL. This regular expressions tutorial is a practical cheat sheet: metacharacters, groups, and examples you can &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[35],"tags":[],"class_list":["post-2294","post","type-post","status-publish","format-standard","hentry","category-algorithms"],"acf":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/2294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=2294"}],"version-history":[{"count":3,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/2294\/revisions"}],"predecessor-version":[{"id":2461,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/2294\/revisions\/2461"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=2294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=2294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=2294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}