Search code examples
javaregex

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


I'm not a native English and so I don't understand well the meaning of 'flavor' may be is it referred to a regex syntax?? and if so how many regex syntax are there?

BRE ERE Perl etc.??


Solution

  • 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 (added in ES2018 - see comment by tony19)
    • PHP and some others support lookbehinds, but needs them to be fixed length
    • Regex engines of text editors (Notepad++) generally don't support lookarounds