Package gnu.regexp
Class RESyntax
java.lang.Object
gnu.regexp.RESyntax
- All Implemented Interfaces:
Serializable
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.
- Author:
- Wes Biggs
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final int
Syntax bit.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final RESyntax
Predefined syntax.static final int
Syntax bit. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclear
(int index) Clear a given bit in this syntax.boolean
get
(int index) Check if a given bit is set in this syntax.Returns the currently active line separator string.Called internally when constructing predefined syntaxes so their interpretation cannot vary.set
(int index) Set a given bit in this syntax.setLineSeparator
(String aSeparator) Changes the line separator string for regular expressions created using this RESyntax.
-
Field Details
-
DEFAULT_LINE_SEPARATOR
-
RE_BACKSLASH_ESCAPE_IN_LISTS
public static final int RE_BACKSLASH_ESCAPE_IN_LISTSSyntax bit. Backslash is an escape character in lists.- See Also:
-
RE_BK_PLUS_QM
public static final int RE_BK_PLUS_QMSyntax bit. Use \? instead of ? and \+ instead of +.- See Also:
-
RE_CHAR_CLASSES
public static final int RE_CHAR_CLASSESSyntax bit. POSIX character classes ([:...:]) in lists are allowed.- See Also:
-
RE_CONTEXT_INDEP_ANCHORS
public static final int RE_CONTEXT_INDEP_ANCHORSSyntax bit. ^ and $ are special everywhere. Not implemented.- See Also:
-
RE_CONTEXT_INDEP_OPS
public static final int RE_CONTEXT_INDEP_OPSSyntax bit. Repetition operators are only special in valid positions. Not implemented.- See Also:
-
RE_CONTEXT_INVALID_OPS
public static final int RE_CONTEXT_INVALID_OPSSyntax bit. Repetition and alternation operators are invalid at start and end of pattern and other places. Not implemented.- See Also:
-
RE_DOT_NEWLINE
public static final int RE_DOT_NEWLINESyntax bit. Match-any-character operator (.) matches a newline.- See Also:
-
RE_DOT_NOT_NULL
public static final int RE_DOT_NOT_NULLSyntax bit. Match-any-character operator (.) does not match a null.- See Also:
-
RE_INTERVALS
public static final int RE_INTERVALSSyntax bit. Intervals ({x}, {x,}, {x,y}) are allowed.- See Also:
-
RE_LIMITED_OPS
public static final int RE_LIMITED_OPSSyntax bit. No alternation (|), match one-or-more (+), or match zero-or-one (?) operators.- See Also:
-
RE_NEWLINE_ALT
public static final int RE_NEWLINE_ALTSyntax bit. Newline is an alternation operator.- See Also:
-
RE_NO_BK_BRACES
public static final int RE_NO_BK_BRACESSyntax bit. Intervals use { } instead of \{ \}- See Also:
-
RE_NO_BK_PARENS
public static final int RE_NO_BK_PARENSSyntax bit. Grouping uses ( ) instead of \( \).- See Also:
-
RE_NO_BK_REFS
public static final int RE_NO_BK_REFSSyntax bit. Backreferences not allowed.- See Also:
-
RE_NO_BK_VBAR
public static final int RE_NO_BK_VBARSyntax bit. Alternation uses | instead of \|- See Also:
-
RE_NO_EMPTY_RANGES
public static final int RE_NO_EMPTY_RANGESSyntax bit. Not implemented.- See Also:
-
RE_UNMATCHED_RIGHT_PAREN_ORD
public static final int RE_UNMATCHED_RIGHT_PAREN_ORDSyntax bit. An unmatched right parenthesis (')' or '\)', depending on RE_NO_BK_PARENS) will throw an exception when compiling.- See Also:
-
RE_HAT_LISTS_NOT_NEWLINE
public static final int RE_HAT_LISTS_NOT_NEWLINESyntax bit. Not implemented.- See Also:
-
RE_STINGY_OPS
public static final int RE_STINGY_OPSSyntax bit. Stingy matching is allowed (+?, *?, ??, {x,y}?).- See Also:
-
RE_CHAR_CLASS_ESCAPES
public static final int RE_CHAR_CLASS_ESCAPESSyntax bit. Allow character class escapes (\d, \D, \s, \S, \w, \W).- See Also:
-
RE_PURE_GROUPING
public static final int RE_PURE_GROUPINGSyntax bit. Allow use of (?:xxx) grouping (subexpression is not saved).- See Also:
-
RE_LOOKAHEAD
public static final int RE_LOOKAHEADSyntax bit. Allow use of (?=xxx) and (?!xxx) apply the subexpression to the text following the current position without consuming that text.- See Also:
-
RE_STRING_ANCHORS
public static final int RE_STRING_ANCHORSSyntax bit. Allow beginning- and end-of-string anchors (\A, \Z).- See Also:
-
RE_COMMENTS
public static final int RE_COMMENTSSyntax bit. Allow embedded comments, (?#comment), as in Perl5.- See Also:
-
RE_CHAR_CLASS_ESC_IN_LISTS
public static final int RE_CHAR_CLASS_ESC_IN_LISTSSyntax bit. Allow character class escapes within lists, as in Perl5.- See Also:
-
RE_SYNTAX_AWK
Predefined syntax. Emulates regular expression support in the awk utility. -
RE_SYNTAX_ED
Predefined syntax. Emulates regular expression support in the ed utility. -
RE_SYNTAX_EGREP
Predefined syntax. Emulates regular expression support in the egrep utility. -
RE_SYNTAX_EMACS
Predefined syntax. Emulates regular expression support in the GNU Emacs editor. -
RE_SYNTAX_GREP
Predefined syntax. Emulates regular expression support in the grep utility. -
RE_SYNTAX_POSIX_AWK
Predefined syntax. Emulates regular expression support in the POSIX awk specification. -
RE_SYNTAX_POSIX_BASIC
Predefined syntax. Emulates POSIX basic regular expression support. -
RE_SYNTAX_POSIX_EGREP
Predefined syntax. Emulates regular expression support in the POSIX egrep specification. -
RE_SYNTAX_POSIX_EXTENDED
Predefined syntax. Emulates POSIX extended regular expression support. -
RE_SYNTAX_POSIX_MINIMAL_BASIC
Predefined syntax. Emulates POSIX basic minimal regular expressions. -
RE_SYNTAX_POSIX_MINIMAL_EXTENDED
Predefined syntax. Emulates POSIX extended minimal regular expressions. -
RE_SYNTAX_SED
Predefined syntax. Emulates regular expression support in the sed utility. -
RE_SYNTAX_PERL4
Predefined syntax. Emulates regular expression support in Larry Wall's perl, version 4, -
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
Predefined syntax. Emulates regular expression support in Larry Wall's perl, version 5. -
RE_SYNTAX_PERL5_S
Predefined syntax. Emulates regular expression support in Larry Wall's perl, version 5, using single line mode (/s modifier).
-
-
Constructor Details
-
RESyntax
public RESyntax()Construct a new syntax object with all bits turned off. This is equivalent to RE_SYNTAX_EMACS. -
RESyntax
Construct a new syntax object with all bits set the same as the other syntax.
-
-
Method Details
-
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.- Returns:
- this object for convenient chaining
-
get
public boolean get(int index) Check if a given bit is set in this syntax. -
set
Set a given bit in this syntax.- Parameters:
index
- the constant (RESyntax.RE_xxx) bit to set.- Returns:
- a reference to this object for easy chaining.
-
clear
Clear a given bit in this syntax.- Parameters:
index
- the constant (RESyntax.RE_xxx) bit to clear.- Returns:
- a reference to this object for easy chaining.
-
setLineSeparator
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.- Returns:
- this object for convenient chaining
-
getLineSeparator
Returns the currently active line separator string. The default is the platform-dependent system property "line.separator".
-