{
    "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups",
    "locale": "en",
    "title": "/J (Duplicate Named Groups): Knowledge hub | DeLaParra Services",
    "description": "Allows multiple capture groups in the same pattern to share the same name — normally a compile-time error.",
    "alternates": {
        "en": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups",
        "nl": "https://delaparra-services.nl/nl/kennisbank/j-duplicate-named-groups"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.csv",
        "md": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.md",
        "json": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.json",
        "zip": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.zip",
        "pdf": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.csv",
            "encodingFormat": "text/csv",
            "name": "j-duplicate-named-groups.csv"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.json",
            "encodingFormat": "application/json",
            "name": "j-duplicate-named-groups.json"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.md",
            "encodingFormat": "text/markdown",
            "name": "j-duplicate-named-groups.md"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.pdf",
            "encodingFormat": "application/pdf",
            "name": "j-duplicate-named-groups.pdf"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.zip",
            "encodingFormat": "application/zip",
            "name": "j-duplicate-named-groups.zip"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups/skills.zip",
            "encodingFormat": "application/zip",
            "name": "j-duplicate-named-groups-skills.zip"
        }
    ],
    "markdown": "1. [Home](<https://delaparra-services.nl/>) \n1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) \n1. [/J (Duplicate Named Groups)](<https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups>)\n\n  \n\nCategory: Regex flags \n\n# /J (Duplicate Named Groups)\n\n  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    \n\n## What is /J (Duplicate Named Groups)?\n\n \n\n/J (Duplicate Named Groups): Allows multiple capture groups in the same pattern to share the same name — normally a compile-time error. The ` J ` modifier in PHP's PCRE lets two capture groups in the same pattern share a name. Normally that is an error, because the engine cannot tell which group you mean. It is useful when a pattern has alternatives that capture the same thing in different ways. Think of a date that may be written as ` 2026-11-25 ` or ` 25/11/2026 `. With ` J `, both branches can capture ` (?<year>...) `, and your code reads ` $m['year'] ` without caring which format matched.\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 /J (Duplicate Named Groups)\n\n  \n\n### What should you keep in mind with /J (Duplicate Named Groups)?\n\n \n\nPCRE also offers ` (?|...) `, a branch reset group, which solves a similar problem with numbered groups. Both make the calling code simpler and the pattern harder to read. If a regex needs this much structure, consider splitting it into two simple patterns tried one after the other. That is usually easier to test and to explain to the next developer.\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- [/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- [/i (Case-Insensitive)](<https://delaparra-services.nl/knowledge-hub/i-case-insensitive>) \n- [/L (Locale-dependent)](<https://delaparra-services.nl/knowledge-hub/l-locale-dependent>) \n- [/m (Multiline)](<https://delaparra-services.nl/knowledge-hub/m-multiline>) \n- [/n (Explicit Capture)](<https://delaparra-services.nl/knowledge-hub/n-explicit-capture>)\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/j-duplicate-named-groups/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/j-duplicate-named-groups)\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/j-duplicate-named-groups#webpage",
                "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups",
                "name": "/J (Duplicate Named Groups): Knowledge hub | DeLaParra Services",
                "description": "Allows multiple capture groups in the same pattern to share the same name — normally a compile-time error.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@type": "DefinedTerm",
                    "@id": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups#term",
                    "name": "/J (Duplicate Named Groups)",
                    "description": "Allows multiple capture groups in the same pattern to share the same name — normally a compile-time error.",
                    "termCode": "j-duplicate-named-groups",
                    "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups",
                    "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/j-duplicate-named-groups#webpage"
                        },
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups#dataset"
                        }
                    ]
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups#breadcrumb"
                },
                "mainEntity": [
                    {
                        "@type": "Question",
                        "name": "What is /J (Duplicate Named Groups)?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Allows multiple capture groups in the same pattern to share the same name — normally a compile-time error. The J modifier in PHP's PCRE lets two capture groups in the same pattern share a name. Normally that is an error, because the engine cannot tell which group you mean. It is useful when a pattern has alternatives that capture the same thing in different ways. Think of a date that may be written as 2026-11-25 or 25/11/2026. With J, both branches can capture (?<year>...), and your code reads $m['year'] without caring which format matched."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What should you keep in mind with /J (Duplicate Named Groups)?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "PCRE also offers (?|...), a branch reset group, which solves a similar problem with numbered groups. Both make the calling code simpler and the pattern harder to read. If a regex needs this much structure, consider splitting it into two simple patterns tried one after the other. That is usually easier to test and to explain to the next developer."
                        }
                    }
                ],
                "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/j-duplicate-named-groups#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": "/J (Duplicate Named Groups)"
                    }
                ]
            },
            {
                "@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/j-duplicate-named-groups#dataset",
                "name": "/J (Duplicate Named Groups)",
                "description": "Allows multiple capture groups in the same pattern to share the same name — normally a compile-time error.",
                "url": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups",
                "identifier": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups#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": "j-duplicate-named-groups.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "j-duplicate-named-groups.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "j-duplicate-named-groups.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "j-duplicate-named-groups.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "j-duplicate-named-groups.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "j-duplicate-named-groups-skills.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups/skills.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    }
                ]
            }
        ]
    }
}