{"id":20565728,"url":"https://github.com/phenax/typed-regex","last_synced_at":"2025-06-16T09:16:28.311Z","repository":{"id":42034677,"uuid":"375433657","full_name":"phenax/typed-regex","owner":"phenax","description":"A typescript library for type-safe regex for named capture groups","archived":false,"fork":false,"pushed_at":"2022-04-16T17:49:58.000Z","size":125,"stargazers_count":93,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-12T14:19:26.035Z","etag":null,"topics":["capture-group","regex","regular-expression","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phenax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["https://www.paypal.me/phenax","https://www.buymeacoffee.com/phenax"],"liberapay":"phenax"}},"created_at":"2021-06-09T17:14:40.000Z","updated_at":"2025-05-14T08:37:30.000Z","dependencies_parsed_at":"2022-09-26T16:22:12.216Z","dependency_job_id":null,"html_url":"https://github.com/phenax/typed-regex","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/phenax/typed-regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Ftyped-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Ftyped-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Ftyped-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Ftyped-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phenax","download_url":"https://codeload.github.com/phenax/typed-regex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Ftyped-regex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260131858,"owners_count":22963459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capture-group","regex","regular-expression","typescript"],"created_at":"2024-11-16T04:38:51.352Z","updated_at":"2025-06-16T09:16:28.282Z","avatar_url":"https://github.com/phenax.png","language":"TypeScript","funding_links":["https://www.paypal.me/phenax","https://www.buymeacoffee.com/phenax","https://liberapay.com/phenax"],"categories":[],"sub_categories":[],"readme":"# typed-regex\nA typescript library for writing type-safe regular expressions using [named capture groups](https://github.com/tc39/proposal-regexp-named-groups).\n\n![GitHub Workflow Status (main)](https://img.shields.io/github/workflow/status/phenax/typed-regex/Node.js%20CI/main)\n[![npm](https://img.shields.io/npm/v/typed-regex)](https://www.npmjs.com/package/typed-regex)\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/typed-regex)](https://www.npmjs.com/package/typed-regex)\n\n\n\n## Install\nTo install the latest stable version of typed-regex -\n```\nyarn add typed-regex\n// OR\nnpm install --save typed-regex\n```\n\n\n## Usage\nThe type of the result object is infered from the regular expression.\n\n```ts\nimport { TypedRegEx } from 'typed-regex';\n\nconst regex = TypedRegEx('^(?\u003cyear\u003e\\\\d{4})-(?\u003cmonth\u003e\\\\d{2})-(?\u003cday\u003e\\\\d{2})$', 'g');\nconst result = regex.captures('2020-12-02');\n\nresult // : undefined | { year: string, month: string, day: string }\n```\n\n\u003e NOTE: The regular expression has to be a string literal for the types to be valid\n\n\n#### Optional properties\nIf the capture group is marked as optional in the regular expression, the generated type will reflect that\n\n```ts\nconst regex = TypedRegEx('(?\u003cfirst\u003e\\\\d+)/(?\u003csecond\u003e\\\\w+)?', 'g');\nconst result = regex.captures('1234/foobar');\n\nresult // : undefined | { first: string, second?: string }\n```\n\n\n#### API Docs\n[You can find more information about the library in the API documentation](https://github.com/phenax/typed-regex/blob/main/docs/API.md)\n\n\n## Browser support\nNamed capture groups are supported in [these browsers](https://caniuse.com/mdn-javascript_builtins_regexp_named_capture_groups)\n\n\n\n## License\nTyped-Regex is licensed under [MIT](./LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Ftyped-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphenax%2Ftyped-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Ftyped-regex/lists"}