{"id":10416,"date":"2026-09-16T07:20:00","date_gmt":"2026-09-16T05:20:00","guid":{"rendered":"https:\/\/www.lukaswojcik.com\/blog\/?p=10416"},"modified":"2026-10-26T11:50:15","modified_gmt":"2026-10-26T10:50:15","slug":"regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition","status":"publish","type":"post","link":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/","title":{"rendered":"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition"},"content":{"rendered":"<p>A regular expression describes a text pattern. The engine is the software that interprets this pattern; flags change options such as whether upper- and lower-case letters are treated alike. Correctness depends on the engine, flags and calling method as well as the pattern itself. Finding a substring is a different operation from validating the complete input.<\/p>\n<p>A successful example alone does not establish either correct boundaries or acceptable running time. The examples below use JavaScript unless another language is named.<\/p>\n<figure class=\"lw-diagram\"><img decoding=\"async\" src=\"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/diagrams\/dia-10416-regex-20261024.png\" width=\"1120\" height=\"580\" loading=\"lazy\" alt=\"JavaScript search over the whole example: 1, 2, 2 and 0 matches. The darker highlight marks the captured group.\"><figcaption>JavaScript search over the whole example: 1, 2, 2 and 0 matches. The darker highlight marks the captured group.<\/figcaption><\/figure>\n<h2>Greediness belongs to the quantifier<\/h2>\n<p>A quantifier specifies how often part of a pattern may repeat. Greedy repetition first tries as much matching text as possible; lazy repetition starts with as little as possible. Either may adjust that choice to match the rest of the pattern.<\/p>\n<p>The dot <code>.<\/code> matches a character; <code>*<\/code> repeats that match greedily. In JavaScript, the dot excludes line terminators unless <code>s<\/code> enables dotAll. A literal period is written <code>\\.<\/code>. In a line with two double-quoted links, <code>href=\"(.*)\"<\/code> can capture from the first opening quote to the last closing quote, including intervening markup.<\/p>\n<p><code>href=\"(.*?)\"<\/code> tries shorter captures first. <code>href=\"([^\"]*)\"<\/code> instead explicitly excludes double quotes from the captured value. Both yield two matches in the illustrated input when the API searches for all matches. Neither pattern is a general HTML parser: alternative quoting, entities and document structure require an HTML parser for robust extraction.<\/p>\n<p>A negated class is not a general guarantee of zero backtracking. For example, <code>[^,]+a<\/code> can give back an already consumed character to satisfy the final <code>a<\/code>. The useful property in the link example is the explicit quote boundary.<\/p>\n<h2>The multiline flag does not constrain character classes<\/h2>\n<p><code>[^&amp;]<\/code> includes line breaks because those characters are not ampersands. The <code>m<\/code> flag changes anchors, not the set of characters consumed by that class. The first expression below therefore produces <strong>one<\/strong> match spanning both lines. Explicitly excluding CR and LF produces two matches:<\/p>\n<figure style=\"--cbb-digits:1\" class=\"cbb cbb--wrap cbb--numbers wp-block-code-beautifier-block-code\" data-lang=\"javascript\"><figcaption class=\"cbb-head\"><span class=\"cbb-lang\">JavaScript<\/span><span class=\"cbb-actions\"><button type=\"button\" class=\"cbb-button cbb-button--wrap\" data-cbb-action=\"wrap\" aria-pressed=\"true\" title=\"Wrap long lines\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M2 4h12M2 8h9.5a2.5 2.5 0 0 1 0 5H8m0 0 1.5-1.5M8 13l1.5 1.5M2 12h3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg><span class=\"cbb-sr\">Wrap long lines<\/span><\/button><button type=\"button\" class=\"cbb-button cbb-button--copy\" data-cbb-action=\"copy\" data-cbb-done=\"Copied\" data-cbb-failed=\"Press Ctrl+C to copy\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><rect x=\"5.5\" y=\"5.5\" width=\"8\" height=\"8.5\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M10.5 3.5V3A1.5 1.5 0 0 0 9 1.5H4A1.5 1.5 0 0 0 2.5 3v6.5A1.5 1.5 0 0 0 4 11h.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><\/svg><span class=\"cbb-button-label\" aria-live=\"polite\">Copy<\/span><\/button><\/span><\/figcaption><pre class=\"cbb-pre\" tabindex=\"0\"><code class=\"cbb-code language-javascript\" style=\"counter-reset:cbb-line 0;\"><span class=\"cbb-line\"><span class=\"cbb-keyword\">const<\/span> text = <span class=\"cbb-string\">'utm_source=newsletter\\nutm_medium=email'<\/span>;\n<\/span><span class=\"cbb-line\"><span class=\"cbb-keyword\">const<\/span> broad = &#91;...text.<span class=\"cbb-function\">matchAll<\/span>(\/^<span class=\"cbb-function\">utm_<\/span>(&#91;a-z_&#93;+)=(&#91;^&amp;&#93;+)$\/gm)&#93;;\n<\/span><span class=\"cbb-line\"><span class=\"cbb-keyword\">const<\/span> bounded = &#91;...text.<span class=\"cbb-function\">matchAll<\/span>(\/^<span class=\"cbb-function\">utm_<\/span>(&#91;a-z_&#93;+)=(&#91;^&amp;\\r\\n&#93;+)$\/gm)&#93;;\n<\/span><span class=\"cbb-line\">console.<span class=\"cbb-function\">log<\/span>(broad.length);   <span class=\"cbb-comment\">\/\/ 1<\/span>\n<\/span><span class=\"cbb-line\">console.<span class=\"cbb-function\">log<\/span>(bounded.length); <span class=\"cbb-comment\">\/\/ 2<\/span>\n<\/span><span class=\"cbb-line\">console.<span class=\"cbb-function\">log<\/span>(broad&#91;<span class=\"cbb-number\">0<\/span>&#93;&#91;<span class=\"cbb-number\">2<\/span>&#93; === <span class=\"cbb-string\">'newsletter\\nutm_medium=email'<\/span>); <span class=\"cbb-comment\">\/\/ true<\/span>\n<\/span><span class=\"cbb-line\">console.<span class=\"cbb-function\">log<\/span>(\/^&#91;<span class=\"cbb-number\">0<\/span>-9&#93;+$\/.<span class=\"cbb-function\">test<\/span>(<span class=\"cbb-string\">'123\\n'<\/span>)); <span class=\"cbb-comment\">\/\/ false (JavaScript, no m)<\/span>\n<\/span><span class=\"cbb-line\">console.<span class=\"cbb-function\">log<\/span>(\/^&#91;<span class=\"cbb-number\">0<\/span>-9&#93;+$\/m.<span class=\"cbb-function\">test<\/span>(<span class=\"cbb-string\">'bad\\n123\\nbad'<\/span>)); <span class=\"cbb-comment\">\/\/ true: one valid line<\/span><\/span><\/code><\/pre><\/figure>\n<p>The bounded example describes a deliberately small line format with a nonempty value. Spaces remain allowed; <code>[^&amp;\\s]+<\/code> would also reject spaces and other whitespace, which is a different rule. CRLF handling and allowed empty values need explicit tests. Actual URL query strings are better read with a URL parser and <code>URLSearchParams<\/code>, including decoding and repeated keys.<\/p>\n<h2>Validation requires checking the complete input<\/h2>\n<p>A search for <code>[0-9]+<\/code> succeeds inside <code>abc123def<\/code>. JavaScript <code>\/^[0-9]+$\/<\/code> without <code>m<\/code> restricts the complete value to ASCII digits. Adding <code>m<\/code> permits a valid line inside an otherwise invalid input. Alternatives also need grouping: <code>^(?:yes|no)$<\/code> applies both anchors to both alternatives.<\/p>\n<p>Anchors check a position, such as the start or end of the input, without consuming a character. Anchor rules vary. Python <code>$<\/code> also accepts a position before a final newline; <code>re.fullmatch(r\"[0-9]+\", value)<\/code> explicitly checks the whole string. PCRE2\/PHP can use <code>\\A[0-9]+\\z<\/code>. Ruby <code>^<\/code> and <code>$<\/code> are line anchors even without a flag; complete-input validation uses <code>\\A<\/code> and <code>\\z<\/code>. Ruby&#8217;s <code>m<\/code> controls dotAll, unlike JavaScript&#8217;s multiline-anchor flag.<\/p>\n<h2>Ambiguous repetition can cause excessive work<\/h2>\n<p>Backtracking means returning to an earlier matching choice when the remaining pattern fails, then trying another choice. Backtracking engines may explore many ways to partition the same text. <code>^(a+)+$<\/code> on a run of <code>a<\/code> characters followed by <code>!<\/code> is a classic risky structure. Removing the redundant outer repetition gives <code>^a+$<\/code> for the same accepted language. Exact duration depends on engine, optimisations, input and limits; no universal thirty-character threshold exists.<\/p>\n<p>Nesting alone is neither proof of exponential behaviour nor the only cause of slow matching. An unanchored search for <code>a+$<\/code> may retry many starting positions on a long failing input, so removing nesting does not justify a general linear-time claim. Overlapping alternatives and an expensive failed branch before a successful branch also matter.<\/p>\n<p>Patterns such as <code>(.*,)*$<\/code> allow zero repetitions and can return an empty match at the end during a search. Describing every input as either a successful fast match or a slow total failure misses that behaviour. A lazy quantifier changes search order; it does not generally remove ambiguous partitions.<\/p>\n<h2>Tests and limits are part of the design<\/h2>\n<p>Useful cases include valid input, two occurrences, invalid prefixes and suffixes, empty input, CR\/LF, Unicode digits, missing delimiters and long near-matches. Expected results should include captured values and match spans, not just a boolean. Three examples are a starting point, not a completeness proof.<\/p>\n<p>Potentially expensive patterns belong in isolated tests with small initial inputs and a strict external deadline or supported engine timeout. Input and pattern-size limits remain useful. A timeout is an error to handle, not proof that the text is invalid.<\/p>\n<div class=\"lw-faq\"><h2>Questions and answers<\/h2>\n<h3>Do atomic groups or possessive quantifiers solve every problem?<\/h3><p>No. Support depends on the engine; Python added both in 3.11. Preventing backtracking can change the accepted language: a greedy possessive part may consume text needed by the following token. Equivalence needs tests.<\/p>\n<h3>What does a linear-time engine guarantee?<\/h3><p>RE2 and Go regexp document linear matching in input length for fixed patterns. Rust regex documents an O(m \u00d7 n) bound for one search, where m reflects pattern size and n input length; repeated-match iterators can have a quadratic bound in n. Unsupported features, pattern compilation, size limits and the selected API still matter. These libraries do not support arbitrary backreferences or lookaround.<\/p>\n<h3>Does \\d always mean ASCII digits?<\/h3><p>JavaScript <code>\\d<\/code> matches 0\u20139. Python string patterns and default .NET behaviour also include Unicode decimal digits; Python&#8217;s ASCII flag and .NET&#8217;s ECMAScript option change relevant behaviour. <code>[0-9]<\/code> expresses an ASCII-only requirement explicitly.<\/p><\/div><div class=\"lw-quellen\"><h2>Sources<\/h2><ul><li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Regular_expressions\" target=\"_blank\" rel=\"noopener noreferrer\">MDN: Regular expressions<\/a><\/li><li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Regular_expressions\/Quantifier\" target=\"_blank\" rel=\"noopener noreferrer\">MDN: Quantifiers<\/a><\/li><li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Regular_expressions\/Input_boundary_assertion\" target=\"_blank\" rel=\"noopener noreferrer\">MDN: Input boundary assertions<\/a><\/li><li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Regular_expressions\/Character_class_escape\" target=\"_blank\" rel=\"noopener noreferrer\">MDN: Character class escapes<\/a><\/li><li><a href=\"https:\/\/docs.python.org\/3\/library\/re.html\" target=\"_blank\" rel=\"noopener noreferrer\">Python: re<\/a><\/li><li><a href=\"https:\/\/www.pcre.org\/current\/doc\/html\/pcre2pattern.html\" target=\"_blank\" rel=\"noopener noreferrer\">PCRE2: Pattern syntax<\/a><\/li><li><a href=\"https:\/\/docs.ruby-lang.org\/en\/master\/Regexp.html\" target=\"_blank\" rel=\"noopener noreferrer\">Ruby: Regexp<\/a><\/li><li><a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/standard\/base-types\/character-classes-in-regular-expressions\" target=\"_blank\" rel=\"noopener noreferrer\">Microsoft: .NET character classes<\/a><\/li><li><a href=\"https:\/\/github.com\/google\/re2\" target=\"_blank\" rel=\"noopener noreferrer\">Google: RE2<\/a><\/li><li><a href=\"https:\/\/pkg.go.dev\/regexp\" target=\"_blank\" rel=\"noopener noreferrer\">Go: regexp<\/a><\/li><li><a href=\"https:\/\/docs.rs\/regex\/latest\/regex\/\" target=\"_blank\" rel=\"noopener noreferrer\">Rust regex: Complexity and untrusted inputs<\/a><\/li><li><a href=\"https:\/\/v8.dev\/blog\/non-backtracking-regexp\" target=\"_blank\" rel=\"noopener noreferrer\">V8: Backtracking and an alternative engine<\/a><\/li><li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/URLSearchParams\" target=\"_blank\" rel=\"noopener noreferrer\">MDN: URLSearchParams<\/a><\/li><\/ul><\/div>","protected":false},"excerpt":{"rendered":"<p>Greedy quantifiers, missing boundaries and ambiguous repetition can produce incorrect matches or excessive processing. Concrete JavaScript examples show how flags, character classes and whole-input validation interact.<\/p>\n","protected":false},"author":1,"featured_media":15173,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[148],"tags":[91297,91144],"class_list":["post-10416","post","type-post","status-publish","format-standard","hentry","category-web-development","tag-data-quality","tag-devops"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition | Lukas Wojcik<\/title>\n<meta name=\"description\" content=\"Why the dot runs too far, why a character class crosses line breaks, and how nested repetition turns a pattern into a program that never finishes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition | Lukas Wojcik\" \/>\n<meta property=\"og:description\" content=\"Why the dot runs too far, why a character class crosses line breaks, and how nested repetition turns a pattern into a program that never finishes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/\" \/>\n<meta property=\"og:site_name\" content=\"Lukas Wojcik - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-16T05:20:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-26T10:50:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10416-what-a-pattern-really-matches-n.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Lukas Wojcik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Lukas Wojcik\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/\"},\"author\":{\"name\":\"Lukas Wojcik\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"headline\":\"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition\",\"datePublished\":\"2026-09-16T05:20:00+00:00\",\"dateModified\":\"2026-10-26T10:50:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/\"},\"wordCount\":941,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10416-what-a-pattern-really-matches-n.png\",\"keywords\":[\"Data Quality\",\"DevOps\"],\"articleSection\":[\"Web Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/\",\"name\":\"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition | Lukas Wojcik\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10416-what-a-pattern-really-matches-n.png\",\"datePublished\":\"2026-09-16T05:20:00+00:00\",\"dateModified\":\"2026-10-26T10:50:15+00:00\",\"description\":\"Why the dot runs too far, why a character class crosses line breaks, and how nested repetition turns a pattern into a program that never finishes.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10416-what-a-pattern-really-matches-n.png\",\"contentUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10416-what-a-pattern-really-matches-n.png\",\"width\":1200,\"height\":630,\"caption\":\"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/web-development\\\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/\",\"name\":\"Lukas Wojcik - Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\",\"name\":\"Lukas Wojcik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"contentUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"width\":424,\"height\":636,\"caption\":\"Lukas Wojcik\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\"},\"sameAs\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition | Lukas Wojcik","description":"Why the dot runs too far, why a character class crosses line breaks, and how nested repetition turns a pattern into a program that never finishes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/","og_locale":"en_US","og_type":"article","og_title":"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition | Lukas Wojcik","og_description":"Why the dot runs too far, why a character class crosses line breaks, and how nested repetition turns a pattern into a program that never finishes.","og_url":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/","og_site_name":"Lukas Wojcik - Blog","article_published_time":"2026-09-16T05:20:00+00:00","article_modified_time":"2026-10-26T10:50:15+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10416-what-a-pattern-really-matches-n.png","type":"image\/png"}],"author":"Lukas Wojcik","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Lukas Wojcik","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#article","isPartOf":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/"},"author":{"name":"Lukas Wojcik","@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"headline":"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition","datePublished":"2026-09-16T05:20:00+00:00","dateModified":"2026-10-26T10:50:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/"},"wordCount":941,"commentCount":0,"publisher":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"image":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#primaryimage"},"thumbnailUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10416-what-a-pattern-really-matches-n.png","keywords":["Data Quality","DevOps"],"articleSection":["Web Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/","url":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/","name":"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition | Lukas Wojcik","isPartOf":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#primaryimage"},"image":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#primaryimage"},"thumbnailUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10416-what-a-pattern-really-matches-n.png","datePublished":"2026-09-16T05:20:00+00:00","dateModified":"2026-10-26T10:50:15+00:00","description":"Why the dot runs too far, why a character class crosses line breaks, and how nested repetition turns a pattern into a program that never finishes.","breadcrumb":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#primaryimage","url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10416-what-a-pattern-really-matches-n.png","contentUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10416-what-a-pattern-really-matches-n.png","width":1200,"height":630,"caption":"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition"},{"@type":"BreadcrumbList","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/web-development\/regular-expressions-the-greedy-dot-missing-anchors-and-nested-repetition\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.lukaswojcik.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Regular Expressions: The Greedy Dot, Missing Anchors and Nested Repetition"}]},{"@type":"WebSite","@id":"https:\/\/www.lukaswojcik.com\/blog\/#website","url":"https:\/\/www.lukaswojcik.com\/blog\/","name":"Lukas Wojcik - Blog","description":"","publisher":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.lukaswojcik.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9","name":"Lukas Wojcik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","contentUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","width":424,"height":636,"caption":"Lukas Wojcik"},"logo":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg"},"sameAs":["https:\/\/www.lukaswojcik.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/10416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/comments?post=10416"}],"version-history":[{"count":7,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/10416\/revisions"}],"predecessor-version":[{"id":26685,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/10416\/revisions\/26685"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/media\/15173"}],"wp:attachment":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/media?parent=10416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/categories?post=10416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/tags?post=10416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}