{"id":28629809,"url":"https://github.com/codebox/regex_parser","last_synced_at":"2025-06-12T12:13:40.483Z","repository":{"id":54313772,"uuid":"42129988","full_name":"codebox/regex_parser","owner":"codebox","description":"A regular expression parser written in JavaScript","archived":false,"fork":false,"pushed_at":"2021-02-24T18:35:43.000Z","size":47,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-11T21:48:13.113Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://codebox.org.uk/pages/regex-parser","language":"JavaScript","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/codebox.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":"2015-09-08T18:04:58.000Z","updated_at":"2022-10-17T14:24:08.000Z","dependencies_parsed_at":"2022-08-13T11:50:14.113Z","dependency_job_id":null,"html_url":"https://github.com/codebox/regex_parser","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/codebox/regex_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fregex_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fregex_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fregex_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fregex_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebox","download_url":"https://codeload.github.com/codebox/regex_parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fregex_parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259462576,"owners_count":22861514,"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":"2025-06-12T12:13:39.499Z","updated_at":"2025-06-12T12:13:40.466Z","avatar_url":"https://github.com/codebox.png","language":"JavaScript","readme":"# regex_parser\nThis is a regular expression parser, written in JavaScript as a learning exercise - if you need to parse a regular expression in JavaScript you should of course use the built-in [RegExp class](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions), and not this implementation.\n\nThis library implements a backtracking [recursive descent parser](https://en.wikipedia.org/wiki/Recursive_descent_parser) and uses [this grammar](https://github.com/codebox/regex_parser/blob/master/grammar.js) to construct a parse tree from the regular expression text that you supply. The parse tree is encapsulated within a regex object, and returned by the `parse.compile()` function. The regex object exposes a `match()` method that can be used to test string values against the expression. The result of a match is contained within an object that has a `matches` property, set to either `true` or `false` to indicate whether the match succeeded or not.\n\n\u003cpre\u003evar regex, match;\nregex = parser.compile('abc+');\nmatch = regex.match('abccc'); // match.matches = true\nmatch = regex.match('abcd');  // match.matches = false\n\u003c/pre\u003e\n\nThe library supports the following symbols:\n\n\u003ctable\u003e\n\n\u003ctbody\u003e\n\n\u003ctr\u003e\n\n\u003cth\u003eSymbol\u003c/th\u003e\n\n\u003cth\u003eExample\u003c/th\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e* (zero or more)\u003c/td\u003e\n\n\u003ctd\u003eabc*\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e+ (one or more)\u003c/td\u003e\n\n\u003ctd\u003eabc+\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e? (zero or one)\u003c/td\u003e\n\n\u003ctd\u003eabc?\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e. (any single character)\u003c/td\u003e\n\n\u003ctd\u003ea.b.c\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e[ ] (inclusive character specification)\u003c/td\u003e\n\n\u003ctd\u003e[A-C][a-c][123]\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e[^ ] (exclusive character specification)\u003c/td\u003e\n\n\u003ctd\u003e[^A-C][^a-c][^123]\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e{ } (exact number of matches)\u003c/td\u003e\n\n\u003ctd\u003ea{5}\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e{ , } (range of matches)\u003c/td\u003e\n\n\u003ctd\u003ea{3,5}\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e{ ,} (lower bounded number of matches)\u003c/td\u003e\n\n\u003ctd\u003ea{3,}\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e| (alternatives)\u003c/td\u003e\n\n\u003ctd\u003edog|cat|hamster\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e() (parentheses)\u003c/td\u003e\n\n\u003ctd\u003ed(i|u|o)g\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e() \\1 (capturing groups)\u003c/td\u003e\n\n\u003ctd\u003e(1|2|3)==\\1\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e\\s and \\S (whitespace/non-whitespace alias)\u003c/td\u003e\n\n\u003ctd\u003e\\S\\s\\S\\s\\S\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\n\u003ctd\u003e\\d and \\D (digit/non-digit alias)\u003c/td\u003e\n\n\u003ctd\u003e\\d\\D\\d\u003c/td\u003e\n\n\u003c/tr\u003e\n\n\u003c/tbody\u003e\n\n\u003c/table\u003e\n\nYou can try some live examples on the [project homepage](http://codebox.org.uk/pages/regex-parser) \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebox%2Fregex_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebox%2Fregex_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebox%2Fregex_parser/lists"}