{"id":13544073,"url":"https://github.com/rluba/uniform","last_synced_at":"2025-04-02T14:30:22.211Z","repository":{"id":45367600,"uuid":"313267884","full_name":"rluba/uniform","owner":"rluba","description":"A fully-featured regular expression library for Jai","archived":false,"fork":false,"pushed_at":"2025-01-02T09:46:45.000Z","size":381,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-02T10:38:42.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/rluba.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":"2020-11-16T10:36:54.000Z","updated_at":"2025-01-02T09:46:49.000Z","dependencies_parsed_at":"2022-09-06T05:01:20.854Z","dependency_job_id":"8da9b4fd-70d8-443f-97b2-9e6432e2ebbd","html_url":"https://github.com/rluba/uniform","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Funiform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Funiform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Funiform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Funiform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rluba","download_url":"https://codeload.github.com/rluba/uniform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246832042,"owners_count":20841096,"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-08-01T11:00:41.618Z","updated_at":"2025-04-02T14:30:21.878Z","avatar_url":"https://github.com/rluba.png","language":null,"funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Uniform – a fully-featured regular expression library for Jai\n\nThis library is a partial port of [RE2](https://github.com/google/re2).\nAs such, it offers \"fast\" expression matching of the full PRCE syntax (except backreferences)\nbut is _not exponential in the length of the input text_.\n\nThis library is still in _very_ rough condition and only minimally tested.\nProceed with caution. There may be dragons.\n\nFor now, it only supports RE2’s general NFA execution engine and\nnone of RE2’s conditional fast-paths (DFA, single-pass NFA, …).\nSo \"fast\" isn’t as fast as it could be for some subsets of regular expressions.\n\nSee [Russ Cox’s excellent article series](https://swtch.com/~rsc/regexp/) for more information about fast regular expression implementations and details about the different execution engines.\n\n## Usage \n\nThe simplest form is:\n\n```Jai\n// Match anywhere in the text:\nmatched, captures := match(\"text_to_search\", \"some\\\\sexpression\\\\b\");\ndefer array_free(captures);\n\n// … or anchor it to require the expression to match the whole text:\nmatched, captures := match(\"text_to_search\", \"some\\\\sexpression\\\\b\", .Anchored_Both);\ndefer array_free(captures);\n```\n\n… after which:\n\n* `matched` indicates whether the expression matched the text,\n* `captures[0]` contains the whole match and\n* `captures[1]` through `[n]` the content of each capture group (`(…)`) in the expression.\n\nThe captures reference segments of the original text, so they’re only valid as long as\nthe text exists. You need to copy them if you want them to persist.\nThis also means that you need to free only the capture array, but not its contents.\n\n### Recommended: compiling the expression\nCompiling the regular expression is the slowest part.\nIf you use an expression multiple times (or want more control about available regular expression features),\nyou should definitely compile it beforehand:\n\n```Jai\nregexp, success := compile(\"some\\\\sexpression\\\\b\");\ndefer uninit(*regexp);\n\n// Use regexp as often as you want…\nfor text: texts {\n\tmatched, captures := match(text, regexp);\n\tdefer array_free(captures);\n}\n```\n\nSee [compile.jai](./compile.jai) and [match.jai](./match.jai) for additional options.\n\n## Running the tests\n\nRunning the tests requires the [`stubborn` module](https://github.com/rluba/stubborn).\nIt’s already included as a submodule, but don’t forget the usual git submodule shenanigans to fetch it.\n\nCompile with `\u003ccompiler\u003e first.jai -- test`, then run the `test` binary.\n(The tests should run at compile-time but this is currently broken in the compiler.)\n\n## Compiling the library\n\nIf you want to compile the library (even though it doesn’t produce any binary),\nyou need the [`ctags` module](https://github.com/rluba/jai-ctags) _in your main jai folder_.\n\n## License\n\nThis library is heavily based on [RE2](https://github.com/google/re2), so their original BSD-style license might still be applicable to some parts.\nOtherwise, this library is licensed under the [MIT license](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frluba%2Funiform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frluba%2Funiform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frluba%2Funiform/lists"}