Skip to content

Regex: Bar not preceded by Foo #763

Answered by RReverser
Yoric asked this question in Q&A
Discussion options

You must be logged in to vote

What you're asking for is essentially negative lookbehind, but absence of lookarounds if one of notable and documented limitations of this crate and similar approaches:

A Rust library for parsing, compiling, and executing regular expressions. Its syntax is similar to Perl-style regular expressions, but lacks a few features like look around and backreferences.

It might be easier to use a regex engine that does support those features, or, alternatively, you'd have to match all \b\w+ar[iy]an\b and then manually filter out the know-to-be-ok ones.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #762 on April 15, 2021 12:28.