An RESyntax specifies the way a regular expression will be compiled.
This class provides a number of predefined useful constants for
emulating popular regular expression syntaxes. Additionally the
user may construct his or her own syntax, using any combination of the
syntax bit constants. The syntax is an optional argument to any of the
matching methods on class RE.
RE_BK_PLUS_QM
public static final int RE_BK_PLUS_QM
Syntax bit. Use \? instead of ? and \+ instead of +.
RE_CHAR_CLASSES
public static final int RE_CHAR_CLASSES
Syntax bit. POSIX character classes ([:...:]) in lists are allowed.
RE_CHAR_CLASS_ESCAPES
public static final int RE_CHAR_CLASS_ESCAPES
Syntax bit. Allow character class escapes (\d, \D, \s, \S, \w, \W).
RE_CHAR_CLASS_ESC_IN_LISTS
public static final int RE_CHAR_CLASS_ESC_IN_LISTS
Syntax bit. Allow character class escapes within lists, as in Perl5.
RE_COMMENTS
public static final int RE_COMMENTS
Syntax bit. Allow embedded comments, (?#comment), as in Perl5.
RE_CONTEXT_INDEP_ANCHORS
public static final int RE_CONTEXT_INDEP_ANCHORS
Syntax bit. ^ and $ are special everywhere.
Not implemented.
RE_CONTEXT_INDEP_OPS
public static final int RE_CONTEXT_INDEP_OPS
Syntax bit. Repetition operators are only special in valid positions.
Not implemented.
RE_CONTEXT_INVALID_OPS
public static final int RE_CONTEXT_INVALID_OPS
Syntax bit. Repetition and alternation operators are invalid
at start and end of pattern and other places.
Not implemented.
RE_DOT_NEWLINE
public static final int RE_DOT_NEWLINE
Syntax bit. Match-any-character operator (.) matches a newline.
RE_DOT_NOT_NULL
public static final int RE_DOT_NOT_NULL
Syntax bit. Match-any-character operator (.) does not match a null.
RE_EMBEDDED_FLAGS
public static final int RE_EMBEDDED_FLAGS
Syntax bit. Allow embedded flags, (?is-x), as in Perl5.
RE_HEX_CHAR
public static final int RE_HEX_CHAR
Syntax bit. Allow hex char (\x1b), as in Perl5.
RE_INTERVALS
public static final int RE_INTERVALS
Syntax bit. Intervals ({x}, {x,}, {x,y}) are allowed.
RE_LIMITED_OPS
public static final int RE_LIMITED_OPS
Syntax bit. No alternation (|), match one-or-more (+), or
match zero-or-one (?) operators.
RE_LOOKAHEAD
public static final int RE_LOOKAHEAD
Syntax bit. Allow use of (?=xxx) and (?!xxx) apply the subexpression
to the text following the current position without consuming that text.
RE_NAMED_PROPERTY
public static final int RE_NAMED_PROPERTY
Syntax bit. Allow named property (\p{P}, \P{p}), as in Perl5.
RE_NESTED_CHARCLASS
public static final int RE_NESTED_CHARCLASS
Syntax bit. Allow nested characterclass ([a-z&&[^p-r]]), as in Java 1.4.
RE_NEWLINE_ALT
public static final int RE_NEWLINE_ALT
Syntax bit. Newline is an alternation operator.
RE_NO_BK_BRACES
public static final int RE_NO_BK_BRACES
Syntax bit. Intervals use { } instead of \{ \}
RE_NO_BK_PARENS
public static final int RE_NO_BK_PARENS
Syntax bit. Grouping uses ( ) instead of \( \).
RE_NO_BK_REFS
public static final int RE_NO_BK_REFS
Syntax bit. Backreferences not allowed.
RE_NO_BK_VBAR
public static final int RE_NO_BK_VBAR
Syntax bit. Alternation uses | instead of \|
RE_OCTAL_CHAR
public static final int RE_OCTAL_CHAR
Syntax bit. Allow octal char (\0377), as in Perl5.
RE_POSSESSIVE_OPS
public static final int RE_POSSESSIVE_OPS
Syntax bit. Possessive matching is allowed (++, *+, ?+, {x,y}+).
RE_PURE_GROUPING
public static final int RE_PURE_GROUPING
Syntax bit. Allow use of (?:xxx) grouping (subexpression is not saved).
RE_STINGY_OPS
public static final int RE_STINGY_OPS
Syntax bit. Stingy matching is allowed (+?, *?, ??, {x,y}?).
RE_STRING_ANCHORS
public static final int RE_STRING_ANCHORS
Syntax bit. Allow beginning- and end-of-string anchors (\A, \Z).
RE_SYNTAX_AWK
public static final RESyntax RE_SYNTAX_AWK
Predefined syntax.
Emulates regular expression support in the awk utility.
RE_SYNTAX_ED
public static final RESyntax RE_SYNTAX_ED
Predefined syntax.
Emulates regular expression support in the ed utility.
RE_SYNTAX_EGREP
public static final RESyntax RE_SYNTAX_EGREP
Predefined syntax.
Emulates regular expression support in the egrep utility.
RE_SYNTAX_EMACS
public static final RESyntax RE_SYNTAX_EMACS
Predefined syntax.
Emulates regular expression support in the GNU Emacs editor.
RE_SYNTAX_GREP
public static final RESyntax RE_SYNTAX_GREP
Predefined syntax.
Emulates regular expression support in the grep utility.
RE_SYNTAX_JAVA_1_4
public static final RESyntax RE_SYNTAX_JAVA_1_4
Predefined syntax.
Emulates regular expression support in Java 1.4's java.util.regex
package.
RE_SYNTAX_PERL4
public static final RESyntax RE_SYNTAX_PERL4
Predefined syntax.
Emulates regular expression support in Larry Wall's perl, version 4,
RE_SYNTAX_PERL4_S
public static final RESyntax RE_SYNTAX_PERL4_S
Predefined syntax.
Emulates regular expression support in Larry Wall's perl, version 4,
using single line mode (/s modifier).
RE_SYNTAX_PERL5
public static final RESyntax RE_SYNTAX_PERL5
Predefined syntax.
Emulates regular expression support in Larry Wall's perl, version 5.
RE_SYNTAX_PERL5_S
public static final RESyntax RE_SYNTAX_PERL5_S
Predefined syntax.
Emulates regular expression support in Larry Wall's perl, version 5,
using single line mode (/s modifier).
RE_SYNTAX_POSIX_AWK
public static final RESyntax RE_SYNTAX_POSIX_AWK
Predefined syntax.
Emulates regular expression support in the POSIX awk specification.
RE_SYNTAX_POSIX_EGREP
public static final RESyntax RE_SYNTAX_POSIX_EGREP
Predefined syntax.
Emulates regular expression support in the POSIX egrep specification.
RE_SYNTAX_SED
public static final RESyntax RE_SYNTAX_SED
Predefined syntax.
Emulates regular expression support in the sed utility.
RE_UNICODE_CHAR
public static final int RE_UNICODE_CHAR
Syntax bit. Allow Unicode char (\u1234), as in Java 1.4.
RE_UNMATCHED_RIGHT_PAREN_ORD
public static final int RE_UNMATCHED_RIGHT_PAREN_ORD
Syntax bit. An unmatched right parenthesis (')' or '\)', depending
on RE_NO_BK_PARENS) will throw an exception when compiling.
clear
public RESyntax clear(int index)
Clear a given bit in this syntax.
index
- the constant (RESyntax.RE_xxx) bit to clear.
- a reference to this object for easy chaining.
get
public boolean get(int index)
Check if a given bit is set in this syntax.
getLineSeparator
public String getLineSeparator()
Returns the currently active line separator string. The default
is the platform-dependent system property "line.separator".
makeFinal
public RESyntax makeFinal()
Called internally when constructing predefined syntaxes
so their interpretation cannot vary. Conceivably useful
for your syntaxes as well. Causes IllegalAccessError to
be thrown if any attempt to modify the syntax is made.
- this object for convenient chaining
set
public RESyntax set(int index)
Set a given bit in this syntax.
index
- the constant (RESyntax.RE_xxx) bit to set.
- a reference to this object for easy chaining.
setLineSeparator
public RESyntax setLineSeparator(String aSeparator)
Changes the line separator string for regular expressions
created using this RESyntax. The default separator is the
value returned by the system property "line.separator", which
should be correct when reading platform-specific files from a
filesystem. However, many programs may collect input from
sources where the line separator is differently specified (for
example, in the applet environment, the text box widget
interprets line breaks as single-character newlines,
regardless of the host platform.
Note that setting the line separator to a character or
characters that have specific meaning within the current syntax
can cause unexpected chronosynclastic infundibula.
- this object for convenient chaining
gnu/regexp/RESyntax.java
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.