{
    "url": "https://delaparra-services.nl/manuals/regex-voor-beginners",
    "locale": "en",
    "title": "Regex for beginners · DeLaParra Services",
    "description": "Reading and writing regular expressions, the main flags (g, i, m, s, u, x), testing them with examples, and using them in VS Code and Laravel validation.",
    "alternates": {
        "en": "https://delaparra-services.nl/manuals/regex-voor-beginners",
        "nl": "https://delaparra-services.nl/nl/handleidingen/regex-voor-beginners"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/manuals/regex-voor-beginners.csv",
        "md": "https://delaparra-services.nl/manuals/regex-voor-beginners.md",
        "json": "https://delaparra-services.nl/manuals/regex-voor-beginners.json",
        "zip": "https://delaparra-services.nl/manuals/regex-voor-beginners.zip",
        "pdf": "https://delaparra-services.nl/manuals/regex-voor-beginners.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/manuals/regex-voor-beginners.csv",
            "encodingFormat": "text/csv",
            "name": "regex-voor-beginners.csv"
        },
        {
            "url": "https://delaparra-services.nl/manuals/regex-voor-beginners.json",
            "encodingFormat": "application/json",
            "name": "regex-voor-beginners.json"
        },
        {
            "url": "https://delaparra-services.nl/manuals/regex-voor-beginners.md",
            "encodingFormat": "text/markdown",
            "name": "regex-voor-beginners.md"
        },
        {
            "url": "https://delaparra-services.nl/manuals/regex-voor-beginners.pdf",
            "encodingFormat": "application/pdf",
            "name": "regex-voor-beginners.pdf"
        },
        {
            "url": "https://delaparra-services.nl/manuals/regex-voor-beginners.zip",
            "encodingFormat": "application/zip",
            "name": "regex-voor-beginners.zip"
        }
    ],
    "markdown": "# Regular expressions for beginners\n\nA **regular expression** (regex) is a search pattern. You use it to find, check or replace text: is this a valid postcode? Find all the telephone numbers in this file.\n\n## The building blocks\n\n| Symbol | Meaning | Example | Found |\n|---|---|---|---|\n| `abc` | exactly this text | `kat` | \"cat\" |\n| `.` | any character (except a new line) | `k.t` | \"cat\", \"kit\" |\n| `\\d` | a digit | `\\d\\d` | \"42\" |\n| `\\w` | letter, number or `_` | `\\w+` | \"invoice_1\" |\n| `\\s` | space, tab or new line | `a\\sb` | \"a b\" |\n| `[abc]` | one of these characters | `[aeiou]` | a vowel |\n| `[^abc]` | anything except these | `[^0-9]` | no digits |\n| `*` | 0 or more times | `ab*` | \"a\", \"abbb\" |\n| `+` | 1 or more times | `\\d+` | \"7\", \"2026\" |\n| `?` | 0 or 1 time | `kleuren?` | \"colour\", \"colours\" |\n| `{n,m}` | n to m times | `\\d{4}` | exactly 4 digits |\n| `^` and `$` | start and end | `^\\d{4}$` | only \"2026\" |\n| `( )` | group | `(ab)+` | \"abab\" |\n| `\\|` | or | `jpg\\|png` | \"jpg\" or \"png\" |\n\n## Flags: how the regex searches\n\nFlags are placed after the pattern (`/patroon/flags`). The most important ones:\n\n| Flag | Name | What it does |\n|---|---|---|\n| `i` | case-insensitive | upper and lower case letters are treated as the same |\n| `g` | global (JavaScript) | all matches rather than just the first one |\n| `m` | multiline | `^` and `$` work on a per-line basis |\n| `s` | dotall | `.` also matches a new line |\n| `u` | Unicode | correct handling of é, ü and emoji |\n| `x` | extended (PHP, Python) | spaces and comments allowed in your pattern |\n\nPlease note: not every language supports the same flags. The **regex-flags-cross-language** skill provides an overview for each language.\n\n## Example: Dutch postcode\n\n```\n^[1-9][0-9]{3}\\s?[A-Z]{2}$\n```\n\n- `^` start\n- `[1-9]` the first digit is not 0\n- `[0-9]{3}` three more digits\n- `\\s?` optionally a space\n- `[A-Z]{2}` two uppercase letters\n- `$` end\n\nIf the `i` flag is set, lower-case letters are also permitted.\n\n## Always test using examples\n\nBefore you write the regex, make a note of what should and what shouldn’t match:\n\n| Must fit | Must not fit |\n|---|---|\n| 9711 AB | 0711 AB |\n| 9711AB | 971 AB |\n| 1234 zz (with `i`) | 9711 ABC |\n\nTest it in the language you’re using it in. An online tester often uses a different ‘flavour’ (JavaScript or PCRE) to your code.\n\n## Regex in VS Code\n\nPress Ctrl+F (Mac: Cmd+F) or Ctrl+Shift+F to search all files, and click the `.*` icon to enable regular expressions. When replacing, you can use groups: search for `(\\w+)@oud\\.nl`, replace with `$1@nieuw.nl`.\n\n## Regex in Laravel validation\n\n```php\n$request->validate([\n    'postcode' => ['required', 'regex:/^[1-9][0-9]{3}\\s?[A-Z]{2}$/i'],\n]);\n```\n\nUse array notation if your pattern contains a `|`. In string notation (`'required|regex:...'`), Laravel splits the string at `|` and your regex will break.\n\n## When there is no regex\n\n- **Email addresses and URLs:** use the built-in `email` and `url` rules.\n- **Reading HTML or JSON:** use a parser (see *Reading and validating JSON*).\n- **Complex patterns with nested `+` and `*` characters:** which can become extremely slow when processing long text.\n\n## Need help?\n\nValidation and input checks that really work are an integral part of **Bespoke software and web applications**.\n\n## Skills\n\n- [Regex builder] (/nl/skills/regex-builder)\n- [Regex flags across languages] (/nl/skills/regex-flags-cross-language)\n\n## Related services\n\n- [Maatwerk software en webapplicaties] (/nl/services#service-03)\n\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "TechArticle",
                "@id": "https://delaparra-services.nl/manuals/regex-voor-beginners#article",
                "url": "https://delaparra-services.nl/manuals/regex-voor-beginners",
                "headline": "Regex for beginners",
                "description": "Reading and writing regular expressions, the main flags (g, i, m, s, u, x), testing them with examples, and using them in VS Code and Laravel validation.",
                "inLanguage": "en",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/manuals/regex-voor-beginners#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/manuals/regex-voor-beginners#dataset",
                "name": "Regex for beginners",
                "description": "Reading and writing regular expressions, the main flags (g, i, m, s, u, x), testing them with examples, and using them in VS Code and Laravel validation.",
                "url": "https://delaparra-services.nl/manuals/regex-voor-beginners",
                "identifier": "https://delaparra-services.nl/manuals/regex-voor-beginners#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/manuals/regex-voor-beginners#article"
                },
                "publisher": {
                    "@type": "Organization",
                    "name": "DeLaParra Services",
                    "url": "https://delaparra-services.nl/"
                },
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/manuals#dataset",
                    "name": "Manuals for working on your own app",
                    "url": "https://delaparra-services.nl/manuals"
                },
                "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": "regex-voor-beginners.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/manuals/regex-voor-beginners.csv",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "regex-voor-beginners.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/manuals/regex-voor-beginners.json",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "regex-voor-beginners.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/manuals/regex-voor-beginners.md",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "regex-voor-beginners.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/manuals/regex-voor-beginners.pdf",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "regex-voor-beginners.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/manuals/regex-voor-beginners.zip",
                        "inLanguage": "en"
                    }
                ]
            }
        ]
    }
}