{"id":47751410,"url":"https://github.com/ieviev/resharp","last_synced_at":"2026-04-03T03:15:09.018Z","repository":{"id":342841974,"uuid":"1172653792","full_name":"ieviev/resharp","owner":"ieviev","description":"RE# - A high-performance, automata based regex engine with first-class support for intersection and complement operations.","archived":false,"fork":false,"pushed_at":"2026-04-02T00:48:12.000Z","size":3947,"stargazers_count":108,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-02T13:05:52.954Z","etag":null,"topics":["automata","regex","regex-engine"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/ieviev.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-04T14:52:30.000Z","updated_at":"2026-04-02T00:48:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ieviev/resharp","commit_stats":null,"previous_names":["ieviev/resharp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ieviev/resharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieviev%2Fresharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieviev%2Fresharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieviev%2Fresharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieviev%2Fresharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ieviev","download_url":"https://codeload.github.com/ieviev/resharp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieviev%2Fresharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31330903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T02:17:30.558Z","status":"ssl_error","status_checked_at":"2026-04-03T02:17:30.071Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["automata","regex","regex-engine"],"created_at":"2026-04-03T03:15:08.381Z","updated_at":"2026-04-03T03:15:09.004Z","avatar_url":"https://github.com/ieviev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RE#\n\n[![crates.io](https://img.shields.io/crates/v/resharp.svg)](https://crates.io/crates/resharp)\n[![docs.rs](https://docs.rs/resharp/badge.svg)](https://docs.rs/resharp)\n\nA high-performance, automata-based regex engine with first-class support for **intersection** and **complement** operations. RE#'s main strength is complex patterns - large lists of alternatives, lookarounds, and boolean combinations - where traditional engines degrade or fall back to slower paths.\n\nRE# compiles patterns into deterministic automata. All matching is non-backtracking with guaranteed linear-time execution. RE# extends standard regex syntax with intersection (`\u0026`), complement (`~`), and a universal wildcard (`_`), enabling patterns that are impossible or impractical to express with standard regex.\n\n[paper](https://dl.acm.org/doi/10.1145/3704837) | [blog post](https://iev.ee/blog/symbolic-derivatives-and-the-rust-rewrite-of-resharp/) | [syntax docs](https://github.com/ieviev/resharp/blob/main/docs/syntax.md) | [dotnet version](https://github.com/ieviev/resharp-dotnet) and [web playground](https://ieviev.github.io/resharp-webapp/)\n\n## Install\n\n```sh\ncargo add resharp\n```\n\n## Usage\n\n```rust\nlet re = resharp::Regex::new(r\".*cat.*\u0026.*dog.*\u0026.{8,15}\").unwrap();\n\nlet matches = re.find_all(b\"the cat and the dog\").unwrap();\nlet found = re.is_match(b\"the cat and the dog\").unwrap();\n```\n\n## Syntax extensions\n\nRE# supports standard regex syntax plus three extensions: `_` (universal wildcard), `\u0026` (intersection), and `~(...)` (complement). `_` matches any character including newlines, so `_*` means \"any string\".\n\n```perl\n_*              any string\na_*             any string that starts with 'a'\n_*a             any string that ends with 'a'\n_*a_*           any string that contains 'a'\n~(_*a_*)        any string that does NOT contain 'a'\n(_*a_*)\u0026~(_*b_*)  contains 'a' AND does not contain 'b'\n(?\u003c=b)_*\u0026_*(?=a)  preceded by 'b' AND followed by 'a'\n```\n\nYou combine all of these with `\u0026` to get more complex patterns. RE# also supports lookarounds (`(?=...)`, `(?\u003c=...)`, `(?!...)`, `(?\u003c!...)`), compiled directly into the automaton with no backtracking.\n\n\u003e RE# is not compatible with some `regex` crate features, eg. lazy quantifiers (`.*?`). See the full [syntax reference](docs/syntax.md) for details.\n\n### When to use RE# over [`regex`](https://crates.io/crates/regex)\n\nThis is a from-scratch rust implementation operating on `\u0026[u8]` / UTF-8 (the [dotnet version](https://github.com/ieviev/resharp-dotnet) uses UTF-16). RE# aims to match `regex` crate performance on standard patterns, with trade-offs on either side. Reasons to reach for RE#:\n\n- intersection, complement, or lookarounds\n- large alternatives with high performance (at the expense of memory)\n- leftmost longest matches rather than leftmost-greedy (PCRE)\n- `find_anchored` and `find_all` (no `find` or `captures`)\n\nMatching returns `Result\u003cVec\u003cMatch\u003e, Error\u003e` - capacity or lookahead overflow will fail outright rather than silently degrade. `EngineOptions` controls precompilation threshold, capacity, and lookahead context:\n\n```rust\nlet opts = resharp::EngineOptions {\n    dfa_threshold: 0,             // eagerly compile up to N states (default: 0 = fully lazy)\n    max_dfa_capacity: 65535,       // max automata states (default: u16::MAX)\n    lookahead_context_max: 800,    // max lookahead context distance (default: 800)\n    hardened: false,               // slower in the average case but truly linear all matches\n    ..Default::default()\n};\nlet re = resharp::Regex::with_options(r\"pattern\", opts).unwrap();\n```\n\n## Benchmarks\n\nThroughput comparison with `regex` and `fancy-regex`, compiled with `--release`. Compile time is excluded; only matching is measured. Uses SIMD intrinsics (AVX2, NEON) with possibly more backends in the near future. Run with `cargo bench -- 'readme/' --list`.\n\n### AMD Ryzen 7 5800X (105W TDP)\n\n| Benchmark | resharp | regex | fancy-regex |\n|---|---|---|---|\n| dictionary 2663 words (900KB, ~15 matches) | **633 MiB/s** | 541 MiB/s | 531 MiB/s |\n| dictionary 2663 words (944KB, ~2678 matches) | **535 MiB/s** | 58 MiB/s | 20 MiB/s |\n| dictionary `(?i)` 2663 words (900KB) | **632 MiB/s** | 0.03 MiB/s | 0.03 MiB/s |\n| lookaround `(?\u003c=\\s)[A-Z][a-z]+(?=\\s)` (900KB) | **460 MiB/s** | -- | 25 MiB/s |\n| `Sherlock\\|Holmes\\|Watson\\|...` (900KB) | **12.0 GiB/s** | 11.2 GiB/s | 10.1 GiB/s |\n| literal `\"Sherlock Holmes\"` (900KB) | 33.2 GiB/s | 34.0 GiB/s | 30.3 GiB/s |\n\n### Rockchip RK3588 ARM (5-10W TDP)\n\n| Benchmark | resharp | regex | fancy-regex |\n|---|---|---|---|\n| dictionary 2663 words (900KB, ~15 matches) | 271 MiB/s | 315 MiB/s | 317 MiB/s |\n| dictionary 2663 words (944KB, ~2678 matches) | **214 MiB/s** | 25 MiB/s | 9 MiB/s |\n| dictionary `(?i)` 2663 words (900KB) | **271 MiB/s** | 0.01 MiB/s | 0.01 MiB/s |\n| lookaround `(?\u003c=\\s)[A-Z][a-z]+(?=\\s)` (900KB) | **198 MiB/s** | -- | 10 MiB/s |\n| `Sherlock\\|Holmes\\|Watson\\|...` (900KB) | 1.73 GiB/s | 2.00 GiB/s | 1.95 GiB/s |\n| literal `\"Sherlock Holmes\"` (900KB) | 6.74 GiB/s | 7.05 GiB/s | 6.78 GiB/s |\n\n**Notes on the results:**\n\n- The first dictionary row is roughly tied - with only ~15 matches, both engines spend most of their time scanning past non-matching bytes, so the DFA strategy difference doesn't show up.\n- On denser matches which force the engines to build more of the state machine the other engines degrade: with ~2678 matches, RE# holds at 535 MiB/s vs 58 MiB/s for `regex` on x86.\n- The `(?i)` row shows what happens when the pattern forces `regex` to fall back to a slower engine: throughput drops to 0.03 MiB/s. RE# handles case folding in the DFA and maintains full speed.\n- RE# compiles lookarounds directly into the automaton - no back-and-forth between forward and backward passes. `regex` doesn't support lookarounds except for anchors; `fancy-regex` handles them via backtracking, which is occasionally much slower.\n- If you encounter a bug or a pattern where RE# is \u003e5x slower than `regex` or `fancy-regex`, please [open an issue](https://github.com/ieviev/resharp/issues) - it would help improve the library. Note that `regex` returns leftmost-greedy (PCRE) matches while RE# returns leftmost-longest, so match results may differ. The performance profile also differs - RE# works right to left while `regex` works left to right.\n- Also see the [rebar](https://github.com/ieviev/rebar) comparison to `regex` - rebar targets leftmost-first engines and its short-input benchmarks measure repeated matching on the same string, so the reported throughput favors `regex` more than varied real-world input would.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fieviev%2Fresharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fieviev%2Fresharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fieviev%2Fresharp/lists"}