{
    "url": "https://delaparra-services.nl/knowledge-hub/g-global",
    "locale": "en",
    "title": "/g (Global): Knowledge hub | DeLaParra Services",
    "description": "Match all occurrences in the string, not just the first one.",
    "alternates": {
        "en": "https://delaparra-services.nl/knowledge-hub/g-global",
        "nl": "https://delaparra-services.nl/nl/kennisbank/g-global"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/knowledge-hub/g-global.csv",
        "md": "https://delaparra-services.nl/knowledge-hub/g-global.md",
        "json": "https://delaparra-services.nl/knowledge-hub/g-global.json",
        "zip": "https://delaparra-services.nl/knowledge-hub/g-global.zip",
        "pdf": "https://delaparra-services.nl/knowledge-hub/g-global.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/knowledge-hub/g-global.csv",
            "encodingFormat": "text/csv",
            "name": "g-global.csv"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/g-global.json",
            "encodingFormat": "application/json",
            "name": "g-global.json"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/g-global.md",
            "encodingFormat": "text/markdown",
            "name": "g-global.md"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/g-global.pdf",
            "encodingFormat": "application/pdf",
            "name": "g-global.pdf"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/g-global.zip",
            "encodingFormat": "application/zip",
            "name": "g-global.zip"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/g-global/skills.zip",
            "encodingFormat": "application/zip",
            "name": "g-global-skills.zip"
        }
    ],
    "markdown": "1. [Home](<https://delaparra-services.nl/>) \n1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) \n1. [/g (Global)](<https://delaparra-services.nl/knowledge-hub/g-global>)\n\n  \n\nCategory: Regex flags \n\n# /g (Global)\n\n  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    \n\n## What is /g (Global)?\n\n \n\n/g (Global): Match all occurrences in the string, not just the first one. The ` g ` flag makes a regular expression find every match, not just the first. In JavaScript, ` 'a-b-c'.replace(/-/g, '+') ` returns ` a+b+c `. Without ` g ` you get ` a+b-c `. It also changes how some methods behave. ` str.match(/x/g) ` returns an array of all matches, while without ` g ` it returns details about the first match only. For all matches with their capture groups, use ` str.matchAll() `, which requires the ` g ` flag.\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 /g (Global)\n\n  \n\n### What should you keep in mind with /g (Global)?\n\n \n\nWatch out for one trap. A regex object with ` g ` remembers where it stopped in its ` lastIndex ` property. Calling ` regex.test() ` twice on different strings with the same object can then give a surprising ` false `. If you reuse a global regex, reset ` lastIndex ` or create the regex inside the function. Modern JavaScript also offers ` replaceAll() ` for plain text replacements.\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- [/D (Dollar End Only)](<https://delaparra-services.nl/knowledge-hub/d-dollar-end-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- [/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- [/J (Duplicate Named Groups)](<https://delaparra-services.nl/knowledge-hub/j-duplicate-named-groups>)\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/g-global/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/g-global)\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/g-global#webpage",
                "url": "https://delaparra-services.nl/knowledge-hub/g-global",
                "name": "/g (Global): Knowledge hub | DeLaParra Services",
                "description": "Match all occurrences in the string, not just the first one.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@type": "DefinedTerm",
                    "@id": "https://delaparra-services.nl/knowledge-hub/g-global#term",
                    "name": "/g (Global)",
                    "description": "Match all occurrences in the string, not just the first one.",
                    "termCode": "g-global",
                    "url": "https://delaparra-services.nl/knowledge-hub/g-global",
                    "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/g-global#webpage"
                        },
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/g-global#dataset"
                        }
                    ]
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/g-global#breadcrumb"
                },
                "mainEntity": [
                    {
                        "@type": "Question",
                        "name": "What is /g (Global)?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Match all occurrences in the string, not just the first one. The g flag makes a regular expression find every match, not just the first. In JavaScript, 'a-b-c'.replace(/-/g, '+') returns a+b+c. Without g you get a+b-c. It also changes how some methods behave. str.match(/x/g) returns an array of all matches, while without g it returns details about the first match only. For all matches with their capture groups, use str.matchAll(), which requires the g flag."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What should you keep in mind with /g (Global)?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Watch out for one trap. A regex object with g remembers where it stopped in its lastIndex property. Calling regex.test() twice on different strings with the same object can then give a surprising false. If you reuse a global regex, reset lastIndex or create the regex inside the function. Modern JavaScript also offers replaceAll() for plain text replacements."
                        }
                    }
                ],
                "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/g-global#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": "/g (Global)"
                    }
                ]
            },
            {
                "@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/g-global#dataset",
                "name": "/g (Global)",
                "description": "Match all occurrences in the string, not just the first one.",
                "url": "https://delaparra-services.nl/knowledge-hub/g-global",
                "identifier": "https://delaparra-services.nl/knowledge-hub/g-global#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/g-global#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": "g-global.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/g-global.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "g-global.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/g-global.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "g-global.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/g-global.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "g-global.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/g-global.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "g-global.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/g-global.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "g-global-skills.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/g-global/skills.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:23+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    }
                ]
            }
        ]
    }
}