{"id":18071573,"url":"https://github.com/cho45/named-regexp.js","last_synced_at":"2025-07-30T11:11:36.049Z","repository":{"id":4283187,"uuid":"5412526","full_name":"cho45/named-regexp.js","owner":"cho45","description":"Append named-capture feature to JavaScript RegExp  ","archived":false,"fork":false,"pushed_at":"2016-06-10T10:46:59.000Z","size":188,"stargazers_count":29,"open_issues_count":4,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-25T22:22:26.248Z","etag":null,"topics":["capture","javascript","regexp"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cho45.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-14T12:33:38.000Z","updated_at":"2019-08-13T15:07:40.000Z","dependencies_parsed_at":"2022-09-09T21:10:44.010Z","dependency_job_id":null,"html_url":"https://github.com/cho45/named-regexp.js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fnamed-regexp.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fnamed-regexp.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fnamed-regexp.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2Fnamed-regexp.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cho45","download_url":"https://codeload.github.com/cho45/named-regexp.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248507968,"owners_count":21115728,"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","javascript","regexp"],"created_at":"2024-10-31T09:15:49.821Z","updated_at":"2025-04-12T02:43:59.684Z","avatar_url":"https://github.com/cho45.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"named-regexp.js\n=================\n\nhttps://github.com/cho45/named-regexp.js\n\nAppend named-capture feature to JavaScript RegExp\n\nSYNOPSYS\n========\n\n    var named = require('named-regexp').named;\n\n    var re = named(/(:\u003cfoo\u003e[a-z]+) (:\u003cfoo\u003e[a-z]+) (:\u003cbar\u003e[a-z]+)/ig);\n    var matched = re.exec('aaa bbb ccc');\n    console.log(matched.captures); //=\u003e { foo: [ 'aaa', 'bbb' ], bar: [ 'ccc' ] }\n    console.log(matched.capture('foo')); //=\u003e 'bbb' // last matched\n\n\n    var replaced = re.replace('aaa bbb ccc ddd eee fff ggg', function (matched) {\n        return matched.capture('bar');\n    });\n\n    console.log(replaced); //=\u003e 'ccc fff ggg');\n\n\nDESCRIPTION\n===========\n\nnamed-regexp.js provides `named` function which converts regexp containing named-captures to normal regexp which has some functions.\n\nnamed-capture is defined by `(:\u003cname\u003eregexp)`. You can't use it with normal captures. If you want to use grouping, use `(?:regexp)` instead.\n\n## Function named()\n\nTakes RegExp object which contains named-captures.\n\nReturns new RegExp object with following methods:\n\n### Method re.exec(string)\n\nPerforms a regexp match of string and returns an Array object containing the results of the match, or null if string did not match.\n\nA returning Array object is same as value from normal RegExp.prototype.exec but it has `captures` property and `capture` method.\n\n#### matched.captures\n\nAn object contains captured values which has capture name as key and array of captured string as its value.\n\n#### matched.capture('name')\n\nReturns last matched string of the name.\n\n### Method re.replace(string, replace)\n\nSame as `String.prototype.replace` but when `replace` is function, this method passes an Array object like value returning from `exec()`.\n\n\nLICENSE\n=======\n\nMIT: http://cho45.github.com/mit-license","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcho45%2Fnamed-regexp.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcho45%2Fnamed-regexp.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcho45%2Fnamed-regexp.js/lists"}