{
    "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only",
    "locale": "en",
    "title": "/D (Dollar End Only): Knowledge hub | DeLaParra Services",
    "description": "Makes $ match only at the very end of the string, never right before a trailing newline (which is $'s default PCRE behaviour).",
    "alternates": {
        "en": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only",
        "nl": "https://delaparra-services.nl/nl/kennisbank/d-dollar-end-only"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.csv",
        "md": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.md",
        "json": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.json",
        "zip": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.zip",
        "pdf": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.csv",
            "encodingFormat": "text/csv",
            "name": "d-dollar-end-only.csv"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.json",
            "encodingFormat": "application/json",
            "name": "d-dollar-end-only.json"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.md",
            "encodingFormat": "text/markdown",
            "name": "d-dollar-end-only.md"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.pdf",
            "encodingFormat": "application/pdf",
            "name": "d-dollar-end-only.pdf"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.zip",
            "encodingFormat": "application/zip",
            "name": "d-dollar-end-only.zip"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only/skills.zip",
            "encodingFormat": "application/zip",
            "name": "d-dollar-end-only-skills.zip"
        }
    ],
    "markdown": "1. [Home](<https://delaparra-services.nl/>) \n1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) \n1. [/D (Dollar End Only)](<https://delaparra-services.nl/knowledge-hub/d-dollar-end-only>)\n\n  \n\nCategory: Regex flags \n\n# /D (Dollar End Only)\n\n  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    \n\n## What is /D (Dollar End Only)?\n\n \n\n/D (Dollar End Only): Makes $ match only at the very end of the string, never right before a trailing newline (which is $'s default PCRE behaviour). In PCRE, ` $ ` normally matches at the end of the string, and also just before a newline at the very end. So ` /^\\d+$/ ` accepts ` \"123\\n\" `. The ` D ` modifier in PHP removes that exception, so ` $ ` only matches at the true end.\n\n \n\nDefinition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)\n\n \n\n## Frequently asked questions about /D (Dollar End Only)\n\n  \n\n### How is /D (Dollar End Only) used in practice?\n\n \n\nThis matters for validation. A value that ends in a newline can slip through a check, then cause trouble later, for example in a header, a file name or a log line. Using ` /^\\d+$/D ` closes that gap.\n\n    \n\n### What should you keep in mind with /D (Dollar End Only)?\n\n \n\nAn easier option that works in most regex engines is ` \\z `, which always means the absolute end of the string. ` /^\\d+\\z/ ` reads clearly and does not depend on a PHP-specific flag. Whichever you choose, add a test case with a trailing newline, because this bug never shows up with the input you type by hand.\n\n \n\n## At a glance\n\n   CategoryRegex flags Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026\n\n \n\n## More Regex flags terms\n\n \n\n- [/A (Anchored)](<https://delaparra-services.nl/knowledge-hub/a-anchored>) \n- [/a (ASCII-only)](<https://delaparra-services.nl/knowledge-hub/a-ascii-only>) \n- [/d (hasIndices)](<https://delaparra-services.nl/knowledge-hub/d-hasindices>) \n- [/e (Eval (deprecated))](<https://delaparra-services.nl/knowledge-hub/e-eval-deprecated>) \n- [/g (Global)](<https://delaparra-services.nl/knowledge-hub/g-global>) \n- [/I (Case-Insensitive (POSIX / grep))](<https://delaparra-services.nl/knowledge-hub/i-case-insensitive-posix-grep>)\n\n \n\n[All terms starting with a number or symbol](<https://delaparra-services.nl/knowledge-hub#letter-other>)\n\n \n\n## Skills\n\n \n\n- ### Regex flags across languages\n\n \n\nUse when writing, porting or debugging a regular expression and its flags/modifiers across languages and tools - JavaScript (g i m s u v y d), PCRE/PHP (i m s x u A D U J), Python re (re.I, re.M, re.S, re.X, re.A), .NET (RegexOptions), POSIX grep/sed. Also use for Laravel \\`regex:\\` validation rules and for catastrophic backtracking risks.\n\n [View skill](<https://delaparra-services.nl/skills/regex-flags-cross-language>) [Download zip](<https://delaparra-services.nl/skills/regex-flags-cross-language/download>) \n- ### Regex builder\n\n \n\nUse when the user asks to create, debug, explain, validate, or optimize a regular expression or replacement for a specific engine. Verifies representative matches, non-matches, captures, escaping, portability limits, and backtracking risk in the target runtime.\n\n [View skill](<https://delaparra-services.nl/skills/regex-builder>) [Download zip](<https://delaparra-services.nl/skills/regex-builder/download>)\n\n [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/d-dollar-end-only/skills.zip>)\n\n \n\n## Manuals\n\n \n\n- [Regex for beginners](<https://delaparra-services.nl/manuals/regex-voor-beginners>) \n- [Installing Visual Studio Code](<https://delaparra-services.nl/manuals/visual-studio-code-installeren>)\n\n \n\n## Related services\n\n \n\n- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)\n\nPerhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet.\n\n \n\n## Need any help?\n\n \n\nStuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.\n\n  [Get in touch](<https://delaparra-services.nl/availability>)\n\n[HTML version](https://delaparra-services.nl/knowledge-hub/d-dollar-end-only)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "FAQPage",
                "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#webpage",
                "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only",
                "name": "/D (Dollar End Only): Knowledge hub | DeLaParra Services",
                "description": "Makes $ match only at the very end of the string, never right before a trailing newline (which is $'s default PCRE behaviour).",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@type": "DefinedTerm",
                    "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#term",
                    "name": "/D (Dollar End Only)",
                    "description": "Makes $ match only at the very end of the string, never right before a trailing newline (which is $'s default PCRE behaviour).",
                    "termCode": "d-dollar-end-only",
                    "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only",
                    "inLanguage": "en",
                    "keywords": "Regex flags",
                    "dateModified": "2026-11-25T17:46:23+00:00",
                    "inDefinedTermSet": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#terms"
                    },
                    "isPartOf": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#dataset"
                    },
                    "subjectOf": [
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#webpage"
                        },
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#dataset"
                        }
                    ]
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#breadcrumb"
                },
                "mainEntity": [
                    {
                        "@type": "Question",
                        "name": "What is /D (Dollar End Only)?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Makes $ match only at the very end of the string, never right before a trailing newline (which is $'s default PCRE behaviour). In PCRE, $ normally matches at the end of the string, and also just before a newline at the very end. So /^\\d+$/ accepts \"123\\n\". The D modifier in PHP removes that exception, so $ only matches at the true end."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "How is /D (Dollar End Only) used in practice?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "This matters for validation. A value that ends in a newline can slip through a check, then cause trouble later, for example in a header, a file name or a log line. Using /^\\d+$/D closes that gap."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What should you keep in mind with /D (Dollar End Only)?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "An easier option that works in most regex engines is \\z, which always means the absolute end of the string. /^\\d+\\z/ reads clearly and does not depend on a PHP-specific flag. Whichever you choose, add a test case with a trailing newline, because this bug never shows up with the input you type by hand."
                        }
                    }
                ],
                "author": {
                    "@id": "https://delaparra-services.nl/#person"
                },
                "mentions": [
                    {
                        "@id": "https://delaparra-services.nl/skills/regex-flags-cross-language#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/skills/regex-builder#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/manuals/regex-voor-beginners#article"
                    },
                    {
                        "@id": "https://delaparra-services.nl/manuals/visual-studio-code-installeren#article"
                    }
                ]
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Knowledge hub",
                        "item": "https://delaparra-services.nl/knowledge-hub"
                    },
                    {
                        "@type": "ListItem",
                        "position": 3,
                        "name": "/D (Dollar End Only)"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#dataset",
                "name": "/D (Dollar End Only)",
                "description": "Makes $ match only at the very end of the string, never right before a trailing newline (which is $'s default PCRE behaviour).",
                "url": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only",
                "identifier": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only#term"
                },
                "creator": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://creativecommons.org/licenses/by/4.0/",
                "creditText": "Coders Lingo (https://coderslingo.com/resources/open-dataset/), CC BY 4.0",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "keywords": "Regex flags",
                "version": "2026-11-25",
                "dateModified": "2026-11-25T17:46:23+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#dataset",
                    "name": "IT terms from A to Z",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "d-dollar-end-only.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "d-dollar-end-only.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "d-dollar-end-only.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "d-dollar-end-only.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "d-dollar-end-only.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "d-dollar-end-only-skills.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/d-dollar-end-only/skills.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    }
                ]
            }
        ]
    }
}