{"id":19834679,"url":"https://github.com/makenowjust/rerejs","last_synced_at":"2025-05-01T17:31:40.425Z","repository":{"id":37049892,"uuid":"245842382","full_name":"makenowjust/rerejs","owner":"makenowjust","description":"Re-implementation of ECMA-262 (JavaScript) RegExp","archived":false,"fork":false,"pushed_at":"2024-11-09T10:00:57.000Z","size":2244,"stargazers_count":27,"open_issues_count":15,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-09T11:16:52.833Z","etag":null,"topics":["ecmascript","javascript","regexp"],"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/makenowjust.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-03-08T15:49:00.000Z","updated_at":"2024-09-21T22:22:16.000Z","dependencies_parsed_at":"2024-02-04T08:21:12.323Z","dependency_job_id":"0ab500c5-33f2-41bd-8019-e624de503c47","html_url":"https://github.com/makenowjust/rerejs","commit_stats":{"total_commits":1087,"total_committers":5,"mean_commits":217.4,"dds":"0.44894204231830726","last_synced_commit":"508e9fbf733fb93089795c061377761dbe8aaeb8"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makenowjust%2Frerejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makenowjust%2Frerejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makenowjust%2Frerejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makenowjust%2Frerejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makenowjust","download_url":"https://codeload.github.com/makenowjust/rerejs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224270299,"owners_count":17283649,"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":["ecmascript","javascript","regexp"],"created_at":"2024-11-12T12:05:23.545Z","updated_at":"2024-11-12T12:05:24.042Z","avatar_url":"https://github.com/makenowjust.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReRE.js\n\n\u003cp\u003e\n  \u003cb\u003eRe\u003c/b\u003e-implementation of ECMA-262 (JavaScript) \u003ccode\u003e\u003cb\u003eR\u003c/b\u003eeg\u003cb\u003eE\u003c/b\u003exp\u003c/code\u003e.\n\u003c/p\u003e\n\n[![codecov](https://codecov.io/gh/MakeNowJust/rerejs/branch/master/graph/badge.svg)](https://codecov.io/gh/MakeNowJust/rerejs)\n[![GitHub Actions status](https://github.com/MakeNowJust/rerejs/workflows/test/badge.svg)](https://github.com/MakeNowJust/rerejs/actions)\n[![NPM version](https://img.shields.io/npm/v/rerejs)](https://www.npmjs.com/package/rerejs)\n\n## About\n\nReRE.js is a framework for processing [ECMA-262][] (JavaScript standard) `RegExp`.\nIt provides:\n\n- **parser** which constructs AST nodes from a `RegExp` pattern string,\n- **engine** which executes `RegExp` matching against an input string, and\n- **ponyfill** (or **shim**) which is complete and full-featured alternative of `RegExp` class.\n\nReRE.js supports the latest `RegExp` features:\n\n- look-behind assertion (`(?\u003c=...)`),\n- named capture group, named back reference (`(?\u003cfoo\u003e...)` and `\\k\u003cfoo\u003e`), and\n- Unicode property class (`\\p{ASCII}`).\n\nMoreover, ReRE.js supports [\"Additional ECMAScript Features for Web Browsers\"][] for `RegExp`.\nIt means robust, so it can parse some terrible real-world `RegExp` patterns correctly.\n\n[ECMA-262]: https://www.ecma-international.org/ecma-262/10.0/index.html\n[\"Additional ECMAScript Features for Web Browsers\"]: https://www.ecma-international.org/ecma-262/10.0/index.html#sec-regular-expressions-patterns\n\n## Getting Started\n\nInstall ReRE.js as dependency:\n\n```console\n$ npm install rerejs\n```\n\nThen, you can start:\n\n```javascript\nimport {\n  // A parser for `RegExp` pattern.\n  Parser,\n  // A compiler for parsed `RegExp` pattern node.\n  Compiler,\n  // A ponyfill of `RegExp`.\n  RegExpCompat\n} from './index';\n\n/*\n * Usage of `Parser`.\n */\n\n// `new Parser` with parsing pattern source and flags,\n// then call `parse` method to execute parsing.\nconst parser = new Parser('a+', 'u');\nconst pattern = parser.parse();\n\nconsole.log(pattern);\n// =\u003e {\n//     type: 'Pattern',\n//     flagSet: {\n//       global: false,\n//       ignoreCase: false,\n//       multiline: false,\n//       unicode: true,\n//       dotAll: false,\n//       sticky: false\n//     },\n//     captureParens: 0,\n//     names: Map(0) {},\n//     child: {\n//       type: 'Some',\n//       nonGreedy: false,\n//       child: { type: 'Char', value: 97, raw: 'a', range: [ 0, 1 ] },\n//       range: [ 0, 2 ]\n//     },\n//     range: [ 0, 2 ]\n//   }\n\n/*\n * Usage of `Compiler`.\n */\n\n// `new Compiler` with pattern node, then call `compile` to get `program`.\nconst compiler = new Compiler(pattern);\nconst program = compiler.compile();\n\n// `program` is compiled regular expression pattern.\n// To execute matching, invoke `exec` method.\n// Note that `program` is not `RegExpCompat` instance,\n// and `exec` method result is not the same as `RegExp.prototype.exec`.\nconsole.log(program.exec('bbaaabb'));\n// =\u003e Match [\n//      0 [0:0] =\u003e '',\n//    ]\n\n/*\n * Usage of `RegExpCompat`.\n */\n\n// You cau use `RegExpCompat` like `RegExp` very.\nconst re = new RegExpCompat('a+', 'u');\n\nconsole.log(re.exec('bbaaabb'));\n// =\u003e [ 'aaa', index: 2, input: 'bbaaabb', groups: undefined ]\n\n// Also, you can pass `RegExpCompat` instance to\n// `String.prototype.match`, `String.prototype.replace`\n// and other methods accepts `RegExp` instance.\nconsole.log('bbaaabb'.match(re));\n// =\u003e [ 'aaa', index: 2, input: 'bbaaabb', groups: undefined ]\nconsole.log('bbaaabb'.replace(re, 'ccc'));\n// =\u003e bbcccbb\n\n// You can write `global.RegExp = RegExpCompat;`,\n// however it does not work as you expected because\n// it does not override `RegExp` literals construction.\n```\n\n## Contributing\n\nReRE.js is *alpha quality* project for now, so there are many bugs and problems.\nIf you found something, please open an issue.\n\nEspecially such reports are needed:\n\n- \"There is a different behavior between the browser and ReRE.js.\"\n- \"`RegExp` matching goes on infinite-loop. VM Bug?\"\n- \"A typo in comment or  error message is found.\"\n\nPull Requests are also welcome.\n\nHowever I concentrate improving ReRE.js ECMA-262 compatibility for now.\nSo, I cannot accept a feature request as soon.\nNotably, it is out of targets of this project that extending `RegExp` syntax.\n(e.g. support `x` flag like  `Perl` regular expression)\n\n## Documents for Developer\n\nThere are few documents for now. Sorry.\n\n- [docs/canonicalize.md](docs/canonicalize.md): the explanation of `src/canonicalize.ts`.\n- [docs/vm.md](docs/vm.md): the explanation for the VM using ReRE.js on matching.\n\n## License\n\nReRE.js is licensed under MIT license.\n\n(C) 2020-2022 TSUYUSATO \"[MakeNowJust][]\" Kitsune\n\n[MakeNowJust]: https://github.com/MakeNowJust\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakenowjust%2Frerejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakenowjust%2Frerejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakenowjust%2Frerejs/lists"}