{"id":18256688,"url":"https://github.com/edwinm/typed-re","last_synced_at":"2026-01-22T14:38:56.694Z","repository":{"id":257808671,"uuid":"867291076","full_name":"edwinm/typed-re","owner":"edwinm","description":"Template literal types for regular expression capturing groups","archived":false,"fork":false,"pushed_at":"2025-09-15T18:18:46.000Z","size":213,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-15T20:23:51.532Z","etag":null,"topics":["capturing-groups","regular-expression","template-literal-types"],"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/edwinm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-03T19:35:01.000Z","updated_at":"2025-09-15T18:18:49.000Z","dependencies_parsed_at":"2025-09-15T20:13:33.999Z","dependency_job_id":"5b11e026-89c6-4d92-9967-a17a89e4c916","html_url":"https://github.com/edwinm/typed-re","commit_stats":null,"previous_names":["edwinm/typed-re"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/edwinm/typed-re","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinm%2Ftyped-re","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinm%2Ftyped-re/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinm%2Ftyped-re/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinm%2Ftyped-re/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edwinm","download_url":"https://codeload.github.com/edwinm/typed-re/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwinm%2Ftyped-re/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28664656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T14:01:31.714Z","status":"ssl_error","status_checked_at":"2026-01-22T13:59:23.143Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["capturing-groups","regular-expression","template-literal-types"],"created_at":"2024-11-05T10:23:14.310Z","updated_at":"2026-01-22T14:38:56.688Z","avatar_url":"https://github.com/edwinm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typed-re\n\n\u003e Template literal types for regular expression capturing groups\n\nWhen using a regular expression to parse a string, use capturing groups and the resulting\n`groups` property will be correctly typed.\n\n## Install\n\n```bash\nnpm install -D typed-re\n```\n\n## Date example\n\n```typescript\nimport {match} from \"typed-re\";\n\nconst dateRe = \"(?\u003cyear\u003e\\\\d{4})-(?\u003cmonth\u003e\\\\d{2})-(?\u003cday\u003e\\\\d{2})\";\n\nconst dateMatch = match(dateRe, \"2024-10-28\");\n\nconsole.log(dateMatch?.groups.day); // OK, will be 28\n\n// console.log(dateMatch?.groups.hour); TYPE ERROR\n```\n\n![typed-re date example](assets/typed-re-date-example.png)\n\n## Email example\n\n```typescript\nimport {match} from \"typed-re\";\n\nconst mailRe = \"^(?\u003cusername\u003e[a-zA-Z0-9._%+-]+)@(?\u003cdomain\u003e[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,})$\"\n\nconst mailMatch = match(mailRe, \"mark@example.com\");\n\nconsole.log(mailMatch?.groups.username); // OK, will be mark\n\n// console.log(mailMatch?.groups.host); TYPE ERROR\n```\n\n## Playground\n\nTry the code above in the TypeScript playground:\n\n[![typed-re date example](assets/ts-playground.svg)](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbxAQxgYwBYF84DMoQhwBEMAnmAKYAmAtFJcQNwBQLA9J13ACKqVxKAD2TgANgK5c2aCADsAzvGr8ASgIC8JABQB+ADxlKyKAD4AOueoIALFgCUtPfpDyYGC1YQAmB04MqZJ7WvvbMMvJKcCowlACyqJhwWijoGNrE3gAM3ja0AIxZtN4AHMQANNFqlPasEYoQEgB0YhAA5tox8YkYuk1tBACuYApNgbVwnHAA8gDSbFOyDc2tHV0JaX0DEMOjGDtQEwCiqqrTqmyXUlNHKMBigiLiktf1UXdi6skkAHrOgwpKFA5KJKKYANrIWgALwAgrQAFpFACcTQA+gBSADUtAAulj7AABZzUQjIYByCFQuGIlFNPFYyxNSEw+EI3E+coOAAkxDe8A+GySKR6GRQUAA1oThKIwM1ZCAKnAPupam9GpQWu1tIKelshiMmgCgSCQDUmJN2DN5hwrUsFBqtR1dZt+ga9hAlMdTucgA)\n\n## Usage\n\n### `match(s, regexp [, flags])`\n\n| Name   | Type              | Description                  |\n|--------|-------------------|------------------------------|\n| s      | string            | String to parse              |\n| regexp | string            | Regular expression as string |\n| flags  | string [optional] | Optional [flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags)        |\n\nReturns the same regex result object as `String.prototype.match()` or `RegExp.prototype.exec()`.\n\n\u003e [!NOTE]\n\u003e The regular expression should be a string, not a regular expression literal.\n\n## License\n\nCopyright 2024 [Edwin Martin](https://bitstorm.org/) and released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwinm%2Ftyped-re","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedwinm%2Ftyped-re","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwinm%2Ftyped-re/lists"}