In the regex world what’s a flavor and which flavor does Java use?

The term “flavor” refers to the regex engine – the syntax and additional properties supported by the particular regex engine.

The Pattern class documents the properties of the Java regex engine.
Aside from the basic things like the meaning of metacharacters, different implementations of regex engines support different types of syntaxes.

For example:

  • POSIX engines support [:digit:] for digits (same as [0-9]);
  • Perl compatible engines support \d shortcut for digits;
  • JavaScript doesn’t support lookbehinds;
  • PHP and some others support lookbehinds, but needs them to be fixed length;
  • Regex engines of text editors (Notepad++) generally don’t support lookarounds.

Leave a Comment