{"id":13710111,"url":"https://github.com/tiehuis/zig-regex","last_synced_at":"2025-04-07T12:03:53.355Z","repository":{"id":43243591,"uuid":"121903044","full_name":"tiehuis/zig-regex","owner":"tiehuis","description":"A regex implementation for the zig programming language","archived":false,"fork":false,"pushed_at":"2024-07-03T12:01:06.000Z","size":150,"stargazers_count":218,"open_issues_count":6,"forks_count":24,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-31T11:03:59.739Z","etag":null,"topics":["regex","regex-engine","zig"],"latest_commit_sha":null,"homepage":null,"language":"Zig","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/tiehuis.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":"2018-02-18T00:00:07.000Z","updated_at":"2025-03-24T06:51:36.000Z","dependencies_parsed_at":"2024-09-24T16:04:23.412Z","dependency_job_id":"35df59dd-5226-4aef-b736-d9b2621f513d","html_url":"https://github.com/tiehuis/zig-regex","commit_stats":{"total_commits":118,"total_committers":13,"mean_commits":9.076923076923077,"dds":"0.43220338983050843","last_synced_commit":"7bc0fd777c3b92c51a94531439e5913bda24030c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiehuis%2Fzig-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiehuis%2Fzig-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiehuis%2Fzig-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiehuis%2Fzig-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiehuis","download_url":"https://codeload.github.com/tiehuis/zig-regex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648976,"owners_count":20972945,"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":["regex","regex-engine","zig"],"created_at":"2024-08-02T23:00:51.948Z","updated_at":"2025-04-07T12:03:53.333Z","avatar_url":"https://github.com/tiehuis.png","language":"Zig","readme":"An automaton-based regex implementation for [zig](http://ziglang.org/).\n\nNote: This is still a work in progress and many things still need to be done.\n\n - [x] Capture group support\n - [ ] UTF-8 support\n - [ ] More tests (plus some automated tests/fuzzing)\n - [x] Add a PikeVM implementation\n - [ ] Literal optimizations and just general performance improvements.\n\n## Usage\n\n```zig\nconst debug = @import(\"std\").debug;\nconst Regex = @import(\"regex\").Regex;\n\ntest \"example\" {\n    var re = try Regex.compile(debug.global_allocator, \"\\\\w+\");\n\n    debug.assert(try re.match(\"hej\") == true);\n}\n```\n\n## Api\n\n### Regex\n\n```zig\nfn compile(a: Allocator, re: []const u8) !Regex\n```\n\nCompiles a regex string, returning any errors during parsing/compiling.\n\n---\n\n```zig\npub fn match(re: *Regex, input: []const u8) !bool\n```\n\nMatch a compiled regex against some input. The input must be matched in its\nentirety and from the first index.\n\n---\n\n```zig\npub fn partialMatch(re: *Regex, input: []const u8) !bool\n```\n\nMatch a compiled regex against some input. Unlike `match`, this matches the\nleftmost and does not have to be anchored to the start of `input`.\n\n---\n\n```zig\npub fn captures(re: *Regex, input: []const u8) !?Captures\n```\n\nMatch a compiled regex against some input. Returns a list of all matching\nslices in the regex with the first (0-index) being the entire regex.\n\nIf no match was found, null is returned.\n\n### Captures\n\n```zig\npub fn sliceAt(captures: *const Captures, n: usize) ?[]const u8\n```\n\nReturn the sub-slice for the numbered capture group. 0 refers to the entire\nmatch.\n\n```zig\npub fn boundsAt(captures: *const Captures, n: usize) ?Span\n```\n\nReturn the lower and upper byte positions for the specified capture group.\n\nWe can retrieve the sub-slice using this function:\n\n```zig\nconst span = caps.boundsAt(0)\ndebug.assert(mem.eql(u8, caps.sliceAt(0), input[span.lower..span.upper]));\n```\n\n---\n\n## References\n\nSee the following useful sources:\n - https://swtch.com/~rsc/regexp/\n - [Rust Regex Library](https://github.com/rust-lang/regex)\n - [Go Regex Library](https://github.com/golang/go/tree/master/src/regexp)\n","funding_links":[],"categories":["Parser","Libraries","Language Essentials"],"sub_categories":["File Format Processing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiehuis%2Fzig-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiehuis%2Fzig-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiehuis%2Fzig-regex/lists"}