What's the most sensible way to emulate lookbehind behavior in Rust regex?

Without a motivating example, it's hard to usefully answer your question in a general way. In many cases, you can substitute lookaround operators with two regexes---one to search for candidates and another to produce the actual match you're interested in. However, this approach isn't always feasible.

If you're truly stuck, then you're only option is to use a regex library that supports these features. Rust has bindings to a couple of them:

  • PCRE
  • PCRE2
  • Oniguruma

There is also a more experimental library, fancy-regex, which is built on top of the regex crate.