{"id":20565737,"url":"https://github.com/phenax/elxr","last_synced_at":"2025-04-14T15:35:31.755Z","repository":{"id":57222742,"uuid":"448023532","full_name":"phenax/elxr","owner":"phenax","description":"Regular expression-like syntax for list operations","archived":false,"fork":false,"pushed_at":"2022-02-17T16:44:41.000Z","size":158,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-10T22:39:29.971Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-14T15:55:18.000Z","updated_at":"2022-02-22T17:15:45.000Z","dependencies_parsed_at":"2022-08-29T04:10:12.951Z","dependency_job_id":null,"html_url":"https://github.com/phenax/elxr","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Felxr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Felxr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Felxr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Felxr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phenax","download_url":"https://codeload.github.com/phenax/elxr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137894,"owners_count":21053775,"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":[],"created_at":"2024-11-16T04:38:54.567Z","updated_at":"2025-04-14T15:35:31.729Z","avatar_url":"https://github.com/phenax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elxr (List expressions)\n\nRegular expression-like syntax for list operations. An experiment generalizing regex-like operations to a list.\n\n[![npm](https://img.shields.io/npm/v/elxr?style=for-the-badge)](https://www.npmjs.com/package/elxr)\n\n\n## Install\nTo install the latest stable version of elxr -\n\n```bash\nyarn add elxr\n// OR\nnpm install --save elxr\n```\n\n\n\n## Syntax\nWhitespaces are ignored (except within literals)\n\n* `\\s` =\u003e Any **string**\n* `\\n` =\u003e Any **number**\n* `\\b` =\u003e Any **boolean**\n* `\\o` =\u003e Any **object** (has to be a record) \u003csup\u003e[TODO]\u003c/sup\u003e\n* `\\a` =\u003e Any **array** \u003csup\u003e[TODO]\u003c/sup\u003e\n* `\\T` =\u003e Any **truthy** value\n* `\\F` =\u003e Any **falsey** value\n* `a|b` =\u003e match `a` **or** `b`\n* `a*` =\u003e **Zero or more** consecutive instances of pattern `a` in the list\n* `a+` =\u003e **One or more** consecutive instances of pattern `a` in the list\n* `a{2, 5}` =\u003e **Min-Max** quantifiers (example matches `a` more than 2 times but less than 5)\n* `(\\s\\T)` =\u003e **Group** (example matches any non-empty string)\n* `^a$` =\u003e `^` indicates **start** of list, and `$` indicates **end** of list \u003csup\u003e[TODO]\u003c/sup\u003e\n* `a,b` =\u003e match `a` on current item followed by `b` on the next item (**sequence**)\n* `[name \\s\\T]` =\u003e match **property** of object (example matches items with property `name` as non-empty string)\n* `\u003e n` | `\u003e= n` | `\u003c n` | `\u003c= n` =\u003e **Comparison** with literal number \u003csup\u003e[TODO]\u003c/sup\u003e\n* `/pat/` =\u003e Test string values against **regex**\n* `\"foobar\"` =\u003e String literal (example matches the string `foobar`)\n* `-2.05` =\u003e Number literal (example matches the number `-2.05`)\n* `true` =\u003e Boolean literal (example matches the value `true`)\n* `(?\u003cmyMatch\u003e \\s\\T)` =\u003e Named capture group (example matches `\\s\\T` pattern with the name `myMatch`) \u003csup\u003e[TODO]\u003c/sup\u003e\n* `(?: \\s\\T)` =\u003e Non-capturing group (example checks for `\\s\\T` but doesn't return it as a match) \u003csup\u003e[TODO]\u003c/sup\u003e\n\n\n\n\n## Examples\n\n#### matchAll\n\n```js\n// | Match for any number or any non-empty string or any object with `prop` is true\nmatchAll(/ \\n | \\s\\T /, [null, 23, '', 'wow', false ]\n\n// \u003e {\n//   groups: [\n//     { index: 1, value: 23 }, // \\n\n//     { index: 3, value: 'wow' }, // \\s\\T\n//   ]\n// }\n```\n\n```js\n// | Match for property `seperator` true, followed by one or more list of id's that are non-empty strings\nmatchAll(/ [seperator true], [id \\s\\T]+ /, [\n  { seperator: true },\n  { id: '1' },\n  { id: '2' },\n  { id: '3' },\n  { seperator: true },\n  { id: '4' },\n  { id: '5' },\n  { id: '6' },\n])\n\n// \u003e {\n//   groups: [\n//     {\n//       index: 0,\n//       value: [\n//         [{ value: { seperator: true }, index: 0 }],\n//         [{ value: [{ id: '1' }, { id: '2' }, { id: '3' }], index: 1 }],\n//       ],\n//     },\n//     {\n//       index: 4,\n//       value: [\n//         [{ value: { seperator: true }, index: 4 }],\n//         [{ value: [{ id: '4' }, { id: '5' }, { id: '6' }], index: 5 }],\n//       ],\n//     },\n//   ]\n// }\n```\n\n\n#### replaceAll\n\n```js\n// | Replace any sequence of one or more numbers by their sum\nconst replacer = (_, matches) =\u003e matches.value.reduce((a, b) =\u003e a + b, 0)\nreplaceAll(/ \\n+ /, replacer, [ 'start', 3, 5, 'mid', 2, 0, 4, 'end' ])\n\n// \u003e [ 'start', 8, 'mid', 6, 'end' ]\n```\n\n\n\n\n## License\nElxr is licensed under [MIT](./LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Felxr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphenax%2Felxr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Felxr/lists"}