rust-lang/regex
View on GitHub ↗ ★ 4,048 Rust
An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.
78 mentions on Hacker News by 39 people: 7 stories, 71 comments · first 2015-01-15 · latest 2026-02-20
20082026
-
…the crates can only interact along `pub` boundaries). [1]: https://docs.rs/regex/latest/regex/ [2]: https://github.com/rust-lang/regex
comment by lesuorac · 2026-02-20 · in Farewell, Rust for web -
…AFAIR need 3rd party packages: Regex Regex is not 3rd party (note the 'rust-lang' in the URL): https://github.com/rust-lang/regex
comment by kouteiheika · 2025-05-10 · in Rust’s dependencies are starting to worry me -
Yes. I'm the one who implemented the case folding the `fd` uses (via its regex engine). See: https://github.com/rust-lang/regex/blob/master/UNICODE.md#rl... And then Unicode itself for more discussion on the topic:…
comment by burntsushi · 2025-03-19 · in fd: A simple, fast and user-friendly alternative to 'find' -
…dependencies for critical components (like regex and async). Regex is not a third-party dependency: https://github.com/rust-lang/regex
comment by kouteiheika · 2025-01-15 · in Build a Database in Four Months with Rust and 647 Open-Source Dependencies -
…To add more color to this, the precise details of what "Unicode support" means are documented here: https://github.com/rust-lang/regex/blob/master/UNICODE.md In effect, all of UTS#18 Level 1 is covered with a couple caveats. This is…
comment by burntsushi · 2024-09-18 · in Rga: Ripgrep, but also search in PDFs, E-Books, Office documents, zip, etc. -
…hitting the z key. Could someone clarify what that means? My interpretation of that was to go to https://github.com/rust-lang/regex/blob/master/regex-cli/arg... and start typing 'z' at the end of line 21, but that doesn't seem to make any…
comment by bogwog · 2024-01-24 · in Zed, a collaborative code editor, is now open source -
…"windowing" patterns and does something clever. I have a ticket open for something similar[1]. [1]: https://github.com/rust-lang/regex/issues/802
comment by burntsushi · 2024-01-03 · in Ugrep – a more powerful, fast, user-friendly, compatible grep -
burntsushi actually regrets making regex replace return a Cow<str>: https://github.com/rust-lang/regex/issues/676#issuecomment-6... . I’m glad it does, and wish it took an impl Into<Cow<str>> there, for the reasons discussed in the issue,…
comment by chrismorgan · 2023-12-05 · in Common Rust Lifetime Misconceptions (2020) -
…[2]: https://docs.rs/regex-automata/latest/regex_automata/meta/st... [3]: https://github.com/rust-lang/regex/blob/837fd85e79fac2a4ea64...
comment by burntsushi · 2023-12-01 · in Advent of Code 2023 is nigh -
It’s not quite that simple, but folks are working on it. https://github.com/rust-lang/regex/issues/425#issuecomment-1... https://github.com/helix-editor/helix/pull/211#issuecomment-...
comment by celeritascelery · 2023-10-10 · in Text showdown: Gap Buffers vs. Ropes -
…production due to catastrophic backtracking now takes on a physical meaning! Separately re: the OP, https://github.com/rust-lang/regex/issues/822 (and specifically BurntSushi's comment at the very end of the issue) adds really useful…
comment by btown · 2023-07-05 · in Regex engine internals as a library -
…a sum type. Here's a "real" version of an AST for a regular expression in all its complex glory: https://github.com/rust-lang/regex/blob/a9b2e02352db92ce1f6e... You can see that it starts out as a sum type at the top level. And inside each…
comment by burntsushi · 2023-03-14 · in Switching from C++ to Rust -
IIRC, that's what the Rust regex engine[1] currently uses [1] https://github.com/rust-lang/regex
comment by SomeoneOnTheWeb · 2023-03-07 · in Show HN: Regex Derivatives (Brzozowski Derivatives) -
This applies to non-backtracking non-DFAs too: https://github.com/rust-lang/regex/issues/787#issuecomment-1... The GitHub issue comment is perhaps a bit high context. I wrote this reddit comment the other day that is lower context and…
comment by burntsushi · 2022-12-30 · in Quickly checking that a string belongs to a small set -
…a lot more useful. See for example people already running into problems with Discord's new feature: https://github.com/rust-lang/regex/issues/127#issuecomment-1... Of course, as I noted, it would be very inappropriate for Discord to permit…
comment by burntsushi · 2022-11-14 · in Python, Catastrophic Regular Expressions and the GIL (2013) -
…regex crate has Unicode support. But it does not support \X. It's more precisely documented here: https://github.com/rust-lang/regex/blob/master/UNICODE.md
comment by burntsushi · 2022-08-21 · in Brian Kernighan adds Unicode support to Awk -
…Feb 2020) [1], etc. [0]: https://github.com/rust-random/rand#rust-version-requirement... [1]: https://github.com/rust-lang/regex#minimum-rust-version-poli...
comment by nicoburns · 2022-06-23 · in Linus Torvalds: Rust for the Kernel Could Possibly Be Merged for Linux 5.20 -
…UTS#18 is a tortured document, but yes, the regex crate supports pretty much all of UTS#18 Level 1: https://github.com/rust-lang/regex/blob/master/UNICODE.md Going beyond Level 1 is difficult.
comment by burntsushi · 2022-06-10 · in Rulex – A new, portable, regular expression language -
…This document outlines Unicode support more precisely for ripgrep's underlying regex engine: https://github.com/rust-lang/regex/blob/master/UNICODE.md
comment by burntsushi · 2022-05-21 · in A simple, fast and user-friendly alternative to ‘find’ -
"Third-party" isn't really correct for regex: https://github.com/rust-lang/regex (note the org) Rust's stdlib is deliberately small in order to allow it to have very strong stability guarantees.
comment by jhugo · 2022-04-11 · in Node.js packages don't deserve trust -
…than Andrew. [1]: https://blog.burntsushi.net/about [2]: https://github.com/BurntSushi/ripgrep [3]: https://github.com/rust-lang/regex [4]: https://github.com/BurntSushi/byteorder [5]: https://crates.io/crates?sort=recent-downloads
comment by stouset · 2021-11-22 · in Rust Moderation Team Resigns -
…of my editing. There's a way to search through rope chunks by using the low level regex-automata: https://github.com/rust-lang/regex/issues/425#issuecomment-7... Alacritty currently does that to search over it's cells, I'd like to look…
comment by archseer · 2021-06-02 · in Helix: a post-modern modal text editor -
Yes, yes and yes. :-) https://github.com/rust-lang/regex/blob/3db8722d0b204a85380f...
comment by burntsushi · 2021-04-23 · in The Boyer-Moore Fast String Searching Algorithm -
…ripgrep already did a good job of dealing with common cases. This is ripgrep's current work-horse: https://github.com/rust-lang/regex/blob/3db8722d0b204a85380f... The revised algorithm is based on the same principles (heuristics derived…
comment by burntsushi · 2021-04-23 · in The Boyer-Moore Fast String Searching Algorithm -
…But only in some cases. See https://github.com/BurntSushi/ripgrep/issues/617#issuecommen... and https://github.com/rust-lang/regex/issues/408 and https://github.com/rust-lang/regex/pull/419 Note though that it is going away soon. It's…
comment by burntsushi · 2021-04-23 · in The Boyer-Moore Fast String Searching Algorithm -
…Discussions opened up, so it's appropriate to ask for help, even if they are beginner questions: https://github.com/rust-lang/regex/discussions As usual though, try to provide as many details as you can. Giving the source code you have but…
comment by burntsushi · 2021-04-13 · in Rust is for Professionals -
…formulation used in Turon's paper wasn't amenable to large classes. Yes, interval sets work great: https://github.com/rust-lang/regex/blob/master/regex-syntax/... This is why I asked if a production grade regex engine based on derivatives…
comment by burntsushi · 2021-03-14 · in Speed of Rust vs. C -
…a couple years since I looked closely, but last I checked, onig was not particularly fast. Compare https://github.com/rust-lang/regex/blob/master/bench/log/07/... vs https://github.com/rust-lang/regex/blob/master/bench/log/07/...
comment by burntsushi · 2021-03-10 · in Debian Running on Rust Coreutils -
…that benchmark. So how does that change your conclusion? The regex crate has many more benchmarks: https://github.com/rust-lang/regex/blob/master/bench/log/07/... and https://github.com/rust-lang/regex/blob/master/bench/log/07/... for…
comment by burntsushi · 2020-12-16 · in Minimal safe Bash script template -
…case it doesn't matter how many other fields there are in the type variant. Here is an example: https://github.com/rust-lang/regex/blob/master/regex-syntax/...
comment by hlasdjlfhalwjk · 2020-08-10 · in Codata in action, or how to connect FP and OOP -
…And actual implementations based on these articles: https://github.com/google/re2 and https://github.com/rust-lang/regex
comment by kccqzy · 2020-05-02 · in Show HN: RegEx for Regular Folk – A visual, example-based introduction -
…at that point, you'd be using the same regex engine. I even maintain official C bindings for them: https://github.com/rust-lang/regex/tree/master/regex-capi EDIT: Oh, and not sure if this is useful, but the regex crate itself should…
comment by burntsushi · 2020-02-24 · in Show HN: Search code in GitHub repos using regular expressions -
> One such engine is rust's https://github.com/rust-lang/regex It can process arbitrary deep nestings? I'm not familiar with it, but I had a look and I can't see anything in there that would allow it to do it. Can you point to syntax that…
comment by rstuart4133 · 2019-09-09 · in Is there a regular expression to detect a valid regular expression? -
…regex (as well as linear time with respect to the length of the input). One such engine is rust's https://github.com/rust-lang/regex
comment by gpm · 2019-09-08 · in Is there a regular expression to detect a valid regular expression? -
I agree, this could be a nice project! If anyone wants to work on it, this is the place to start: https://github.com/rust-lang/regex/blob/master/src/literal/t... I'll get to it myself eventually if someone else doesn't, but it will likely…
comment by burntsushi · 2019-04-16 · in Ripgrep 11 Released -
…isn't particularly good. I'll keep your advice about SSE 4.2 in mind should I revisit that code. https://github.com/rust-lang/regex/blob/master/src/literal/t... might be of interest to casual readers (not necessarily you, considering you…
comment by blattimwind · 2019-03-30 · in Why GNU grep is fast (2010) -
…(or specifically, the Rust regex crate) takes inspiration from Hyperscan for its SIMD matching. https://github.com/rust-lang/regex/commit/203c509df9e1dcba61... Both libraries also rely on a number of techniques from existing published…
comment by lambda · 2019-02-28 · in Hyperscan: A Fast Multi-Pattern Regex Matcher for Modern CPUs -
…than the go one. [1] https://docs.rs/regex/1.1.0/regex/ [2] - C (and thus everything with a FFI): https://github.com/rust-lang/regex/tree/master/regex-capi - Go (heh): https://github.com/BurntSushi/rure-go - Possibly somewhat out of date…
comment by gpm · 2019-02-26 · in The most popular docker images each contain at least 30 vulnerabilities -
For Rust , many say that the regex crate sets a high standard for excellence: https://github.com/rust-lang/regex
comment by Dowwie · 2018-09-21 · in Ask HN: What open source project, in your opinion, has the highest code quality? -
…something I'd like to work on. I don't know if I'll succeed, but I've documented my thoughts here: https://github.com/rust-lang/regex/issues/425 --- If you'd like to elaborate and go more in depth about the specific use cases you have, I'd…
comment by burntsushi · 2018-07-31 · in Doug McIlroy's C++ regular expression matching library -
…this feature and a real-world implementation, check out the PR adding support to the regex library: https://github.com/rust-lang/regex/pull/456
comment by kibwen · 2018-06-21 · in Announcing Rust 1.27 -
…depending on whether they’re using nightly, with all the unstable features enabled, or not. [1] https://github.com/rust-lang/regex/pull/490
comment by computerphage · 2018-06-21 · in Announcing Rust 1.27 -
…for example will very rarely use Boyer Moore. Its work horse is much simpler and typically faster: https://github.com/rust-lang/regex/blob/master/src/literal/m... In Go-land, you should be able to replace uses of memchr with IndexByte[1],…
comment by burntsushi · 2018-06-06 · in Show HN: Grep with colours written in Go -
…C++ and D libraries), but they are very minimal bindings sufficient for rough microbenchmarking: https://github.com/rust-lang/regex/tree/master/bench/src/ffi
comment by burntsushi · 2018-02-10 · in Regular Expression Matching Can Be Simple and Fast (2007) -
…This behavior can be disabled with the '-I' flag, if needed. fd uses Rusts regex engine ( https://github.com/rust-lang/regex ) which is based on finite automata.
comment by sharkdp · 2017-10-08 · in Show HN: A simple, fast and user-friendly alternative to find, written in Rust -
…and in Rust, it's a `extern "C" fn foo() ...` function declaration. You can see an example here: https://github.com/rust-lang/regex/tree/master/regex-capi Adding C++ ABI support is a significant effort.
comment by burntsushi · 2017-08-31 · in Announcing Rust 1.20 -
…times 3 = 249, which buts up against a hard-coded limit in the regex engine for literal detection: https://github.com/rust-lang/regex/blob/d894c631cb6c9a062c13... In this case, the literal detector knows that the literal is a prefix. That…
comment by burntsushi · 2017-07-04 · in Skip grep, use awk -
…a decent write-up for us in the Rust reimplementation of our "Teddy" literal matcher. Please see https://github.com/rust-lang/regex/blob/master/src/simd_acce... if interested or look up the Hyperscan project at…
comment by glangdale · 2017-05-26 · in Writing a Fast JSON Parser -
…facing performance issues with Go's regex engine. [1] https://github.com/BurntSushi/rure-go [2] https://github.com/rust-lang/regex
comment by stymaar · 2017-03-21 · in The 1960's elegance behind Go's regexp -
…structure and a regex! compiler plugin, the latter is currently significantly slower at runtime : https://github.com/rust-lang/regex#usage-regex-compiler-plug...
comment by masklinn · 2017-02-14 · in Hero – A handy, fast and powerful Go template engine