tags:

views:

78

answers:

6

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.??

A: 

Java uses perl like reg-ex syntax

Reddy
+1  A: 

A "flavor" in this context is a particular syntax, as you have surmised. There are many; counting them would be only an academic endeavor.

To find the ones that are generally used, look at the forms accepted by grep.

Java may use whatever syntax has a Java implementation.

Borealid
+6  A: 

There are many different variations of what features a regex engine implements, what technique it uses "under the hood" and what syntax it uses for certain features.

There is a very good article and comparison table at regular-expressions.info.

The Java regex package implements a "Perl-like" regular expressions engine, but it has some extra features like possessive quantifiers (.*+) and variable-length (but finite) lookbehind assertions). On the other hand, it misses a few features Perl has, namely conditional expressions or comments. All in all, it's a very full-featured implementation.

Tim Pietzcker
+1  A: 

A nice overview can be found here: Comparison of Regular Expression Engines.

Andreas_D
A: 

Regular-expression.info has a page about flavor comparisons.

Jens
+1  A: 
  • Flavor refers to the regex engine - the syntax and additional properties supported by the particular regex engine.
  • 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 look behinds
    • PHP and some others support look behinds, but needs them to be fixed length
    • Regex engines of text editors (Notepad++) generally don't support look around.
Amarghosh