I wanted to know java supports which standards for regular expression. By the word standards i mean does it support IEEE POSIX BRE, ERE, and SRE.
Can anyone give any idea.
Thanks in advance for the reply.
This document from Oracle contains extensive information regarding supported regex constructs in Java SE 7, although it does not mention what kind of standards are supported:
Comparison to Perl 5
The Pattern engine performs traditional NFA-based matching with ordered alternation as occurs in Perl 5.
Perl constructs not supported by this class:
- Predefined character classes (Unicode character)
\h
A horizontal whitespace\H
A non horizontal whitespace\v
A vertical whitespace\V
A non vertical whitespace\R
Any Unicode linebreak sequence\u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029]
\X
Match Unicode extended grapheme cluster- The backreference constructs,
\g{n}
for the nthcapturing group and \g{name} for named-capturing group.- The named character construct,
\N{name}
for a Unicode character by its name.- The conditional constructs
(?(condition)X)
and(?(condition)X|Y)
,- The embedded code constructs
(?{code})
and(??{code})
,- The embedded comment syntax
(?#comment)
, and- The preprocessing operations
\l
,\u
,\L
, and\U
.Constructs supported by this class but not by Perl:
- Character-class union and intersection as described above.
Notable differences from Perl:
In Perl,
\1
through\9
are always interpreted as back references; a backslash-escaped number greater than 9 is treated as a back reference if at least that many subexpressions exist, otherwise it is interpreted, if possible, as an octal escape. In this class octal escapes must always begin with a zero. In this class,\1
through\9
are always interpreted as back references, and a larger number is accepted as a back reference if at least that many subexpressions exist at that point in the regular expression, otherwise the parser will drop digits until the number is smaller or equal to the existing number of groups or it is one digit.Perl uses the
g
flag to request a match that resumes where the last match left off. This functionality is provided implicitly by theMatcher
class: Repeated invocations of the find method will resume where the last match left off, unless the matcher is reset.In Perl, embedded flags at the top level of an expression affect the whole expression. In this class, embedded flags always take effect at the point at which they appear, whether they are at the top level or within a group; in the latter case, flags are restored at the end of the group just as in Perl.