What RegEx flavor to use

When constructing RegEx syntax with the help of dedicated tools, I have to specify the RegEx flavor to use.

The Anki help file points to a programming language called “Rust”. However, this is not listed in my RegEx helper tool. It requires me to choose between Perl, Python, Delphi, C#, C++, PCRE, Ruby, Java, etc… — Rust is not among the choices available.

Does anyone know whether

  • Rust is indeed the correct flavor to use?
  • And if so, what comes closest to Rust, so I could use, say, PCRE or Java instead.

I’m curious what the answer to your question is … but I can recommend my favorite regex helper tool (which happens to include Rust) – https://regex101.com/ .

3 Likes

Seems to be Rust.

For the specifics of Anki’s regex support, please see the regex crate documentation: regex - Rust
From Searching - Anki Manual (ankiweb.net)

And as Danika_Dakika mentioned above, you could use regex101: build, test, and debug regex to use Rust flavor regex.

1 Like

Anki uses Rust’s regex package. You can consult its docs for its specifics.

2 Likes

Thank you all, and also for linking me to resources. Very useful indeed, the regex101 especially.

So Rust it is. A language I did not even know existed. Seems like every time I tinker with a new app, I have to adapt to a new Regex flavor. They look identical, but the devil lurks in the details. Learned that the hard way, hence my question, to avoid frustrations down the road.

Will ask the author of my tool to include Rust in a future update. Until then, and for the record:

Rust is similar to Perl, but lacks some features, such as look-around and back-references.

1 Like