{"id":15067400,"url":"https://github.com/soc221b/regexp-to-path","last_synced_at":"2026-01-08T19:04:33.099Z","repository":{"id":257080680,"uuid":"857213471","full_name":"soc221b/regexp-to-path","owner":"soc221b","description":"Turn a regular expression (named capturing group) into a path string","archived":false,"fork":false,"pushed_at":"2024-12-29T03:54:21.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T04:39:41.651Z","etag":null,"topics":["angular","path-to-regexp","react","router","vue"],"latest_commit_sha":null,"homepage":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_capturing_group","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/soc221b.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}},"created_at":"2024-09-14T04:09:37.000Z","updated_at":"2024-12-31T20:14:38.000Z","dependencies_parsed_at":"2025-01-22T17:11:51.185Z","dependency_job_id":"3b13cc5f-1979-484c-93b0-8c5a37771e3c","html_url":"https://github.com/soc221b/regexp-to-path","commit_stats":null,"previous_names":["soc221b/regexp-to-path"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soc221b%2Fregexp-to-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soc221b%2Fregexp-to-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soc221b%2Fregexp-to-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soc221b%2Fregexp-to-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soc221b","download_url":"https://codeload.github.com/soc221b/regexp-to-path/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246598699,"owners_count":20803071,"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":["angular","path-to-regexp","react","router","vue"],"created_at":"2024-09-25T01:20:39.548Z","updated_at":"2026-01-08T19:04:33.049Z","avatar_url":"https://github.com/soc221b.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RegExp-to-Path\n\n\u003e Turn a regular expression (e.g., `/\\/user\\/(?\u003cid\u003e[^/]+)/`) into a path string (e.g., `\"/user/:id\"`).\n\n## Comparison\n\n### Parameters\n\nRegExp: `/\\/user\\/(?\u003cid\u003e[^/]+)/`\n\nMatches: `/user/1`, `/user/2`, `/user/3`, etc.\n\n|                | Path        | Document                                                                 |\n| -------------- | ----------- | ------------------------------------------------------------------------ |\n| Angular        | `/user/:id` | https://angular.dev/guide/routing/router-reference#configuration         |\n| Path-To-RegExp | `/user/:id` | https://github.com/pillarjs/path-to-regexp?tab=readme-ov-file#parameters |\n| React          | `/user/:id` | https://reactrouter.com/start/framework/routing#dynamic-segments         |\n| Vue            | `/user/:id` | https://router.vuejs.org/guide/essentials/dynamic-matching.html          |\n\n### Optional\n\nRegExp: `/(?:\\/(?\u003clang\u003e[^/]+))?\\/categories/`\n\nMatches: `/categories`, `/en/categories`, `/fr/categories`, etc.\n\n|                | Path                  | Document                                                                                 |\n| -------------- | --------------------- | ---------------------------------------------------------------------------------------- |\n| Angular        | -                     | https://angular.dev/guide/routing/routing-with-urlmatcher                                |\n| Path-To-RegExp | `{/:lang}/categories` | https://github.com/pillarjs/path-to-regexp?tab=readme-ov-file#optional                   |\n| React          | `/:lang?/categories`  | https://reactrouter.com/start/framework/routing#optional-segments                        |\n| Vue            | `/:lang?/categories`  | https://router.vuejs.org/guide/essentials/route-matching-syntax.html#Optional-parameters |\n\n### Repeatable\n\nRegExp: `/\\/files(?\u003cpath\u003e\\/[^\\/]+?)*/`. (needs to extract each segment manually)\n\nMatches: `/files/1`, `/files/1/2`, `/files/1/2/3`, etc.\n\n|                | Path            | Document                                                                               |\n| -------------- | --------------- | -------------------------------------------------------------------------------------- |\n| Angular        | -               | https://angular.dev/guide/routing/routing-with-urlmatcher                              |\n| Path-To-RegExp | `/files/*path`  | https://github.com/pillarjs/path-to-regexp?tab=readme-ov-file#wildcard                 |\n| React          | `/files/*`      | https://reactrouter.com/start/framework/routing#splats                                 |\n| Vue            | `/files/:path*` | https://router.vuejs.org/guide/essentials/route-matching-syntax.html#Repeatable-params |\n\n### Wildcard\n\nRegExp: `/.*/`\n\nMatches: anything\n\n|                | Path               | Document                                                                                      |\n| -------------- | ------------------ | --------------------------------------------------------------------------------------------- |\n| Angular        | `**`               | https://angular.dev/guide/routing/router-reference#configuration                              |\n| Path-To-RegExp | `/*path`           | https://github.com/pillarjs/path-to-regexp?tab=readme-ov-file#wildcard                        |\n| React          | `*`                | https://reactrouter.com/start/framework/routing#splats                                        |\n| Vue            | `/:pathMatch(.*)*` | https://router.vuejs.org/guide/essentials/dynamic-matching.html#Catch-all-404-Not-found-Route |\n\n## Demo\n\n```ts\n// For Path-to-regexp, e.g., `/\\/user\\/(?\u003cid\u003e[^/]+)/` `\"/user/:id\"`\nimport { regExpToPath } from \"regexp-to-path\";\n\n// For Angular, e.g., `/.*/` `\"**\"`\n// import { regExpToPathAngular } from \"regexp-to-path\";\n\n// For React, e.g., `/\\/project(?:\\/task)?\\/(?\u003ctaskId\u003e[^/]+)/` `\"/project/task?/:taskId\"`\n// import { regExpToPathReact } from \"regexp-to-path\";\n\n// For Vue, e.g., `/\\/(?\u003cchapters\u003e\\d*)/` `\"/:chapters(\\\\d+)*\"`\n// import { regExpToPathVue } from \"regexp-to-path\";\n```\n\n```ts\nregExpToPath(/\\/user\\/(?\u003cid\u003e[^/]+)/);\n//=\u003e \"/user/:id\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoc221b%2Fregexp-to-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoc221b%2Fregexp-to-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoc221b%2Fregexp-to-path/lists"}