Class Catalog
java.lang.Object
aQute.libg.re.Catalog
This class provides an implementation of the RE types. The class is useful as
static imports. (For Eclipse users, look at favorites in the preferences.)
However, it can also be used as base class. If that is the case, field names
can be used as named capture groups. In this constellation, the static
methods are also in scope, not requiring many static imports.
void foo() {
class X extends Catalog {
RE match = lit("abc");
RE namedMatch = named(match);
}
X x;
x.....
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RE.Cstatic final REstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final REstatic RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final REstatic final REstatic final REstatic final REstatic final REstatic final REstatic final REstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final REstatic final RE.Cstatic RE.Cstatic REstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final REstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final REstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Qstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final RE.Qstatic final RE.Qstatic final REstatic final RE.Qstatic final RE.Cstatic final RE.Cstatic final REstatic final RE.Cstatic final RE.Cstatic final RE.Cstatic final REstatic final RE.Qstatic final REstatic final RE.Cstatic final RE.Cstatic final RE.C -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RE.GCreates a lookahead group with the provided regular expressions.static RECreates a regular expression that matches anything except the specified string.static RE.QCreates a quantified regular expression that matches at least a specified minimum number of occurrences.static RE.QCreates a quantified regular expression that matches at least a specified minimum number of occurrences of a literal string.static RE.GCombine the res into a single atomic Group.static RE.GCreates an atomic group with the provided string.static REback(int group) Used to reference a previous capturing group.static REUsed to reference a previous named capturing group.static RE.GCreates a lookbehind group with the provided regular expressions.static RE.GCreates a capturing group with the provided regular expressions.static RE.FcaseInsenstive(RE... res) Applies the case-insensitive flag to the provided regular expressions.static RE.FcaseInsenstiveOff(RE... res) Turns off the case-insensitive flag for the provided regular expressions.static RE.CCreate a character class.static RE.FApplies the comments flag to the provided regular expressions.static RE.FcommentsOff(RE... res) Turns off the comments flag for the provided regular expressions.static REcontrol(char c) Return a control char.static RE.FApplies the dotall flag to the provided regular expressions.static RE.FTurns off the dotall flag for the provided regular expressions.static RECreate a non capturing groupstatic RECreate a named capturing groupstatic REModifies the given quantified regular expression to match greedily.static RECreates a conditional regular expression with no alternative case.static RECreates a conditional regular expression.static RECreate a list of clauses separated by a comma.static RECreate a list of clauses separated by a separator.static REProvide a literal text.static RE[]Useful if you need a number of literal REsstatic RECreates a regular expression that optionally matches the given string.static RE.FApplies the multiline flag to the provided regular expressions.static RE.FmultilineOff(RE... res) Turns off the multiline flag for the provided regular expressions.static RE.QCreates a quantified regular expression that matches a specified minimum and maximum number of occurrences.static RE.QCreates a quantified regular expression that matches a specified minimum and maximum number of occurrences of a literal string.If this class is extended, the named fields in that class can be used in named groups.static RECreates a regular expression that matches the negation of the provided regular expression.static RE.QReturn an optional REstatic RE.QReturn an optional literal (seelit(String)tstatic RECreate an OR combination of a number of RE'sstatic RECreate an or combination of character classes.static RECreate an OR combination of a number of Strings.static REModifies the given quantified regular expression to match in a possessive manner.static REUse the quoting facility built intoPattern.quote(String)static REstatic REModifies the given quantified regular expression to match reluctantly.static RE.GCreates a sequence of regular expressions.static RE.QReturn a group of some members.static RE.QReturn a group of some members.static REstring(char delimeter) Return a string that is delimeted on both sides with the same character.static RESeeterm(String,RE...)with a null for namestatic REReturn a named group but where each member that is not a whitespace, will be preceded with a #setWs.static REUse the Unicode name.static RE.FunicodeCase(RE... res) Applies the unicode case flag to the provided regular expressions.static RE.FunicodeCaseOff(RE... res) Turns off the unicode case flag for the provided regular expressions.static RE.FunicodeCharacterClass(RE... res) Applies the unicode character class flag to the provided regular expressions.static RE.FunicodeCharacterClassOff(RE... res) Turns off the unicode character class flag for the provided regular expressions.static RE.FApplies the unix lines flag to the provided regular expressions.static RE.FunixLinesOff(RE... res) Turns off the unix lines flag for the provided regular expressions.static RECreates a regular expression that matches 'thenExpect' until 'condition' becomes true.static RECreates a regular expression that repeats the 'thenExpect' pattern as long as 'condition' matches.
-
Field Details
-
ws
-
setWs
-
someWs
-
all
-
setAll
-
someAll
-
backslash
-
Lu
-
Ll
-
Lt
-
Lm
-
Lo
-
Nd
-
Nl
-
No
-
Z
-
P
-
S
-
Cc
-
Cf
-
Cn
-
Lower
-
Upper
-
ASCII
-
Alpha
-
Digit
-
Alnum
-
Punct
-
Graph
-
Print
-
Blank
-
Cntrl
-
XDigit
-
Space
-
letter
-
dollar
-
euro
-
word
-
digit
-
nonDigit
-
lineEnd
-
dot
-
comma
-
semicolon
-
colon
-
nl
-
cr
-
lf
-
ff
-
alarm
-
escape
-
eof
-
eol
-
parOpen
-
parClose
-
empty
-
tab
-
number
-
hexdigit
-
bindigit
-
hexnumber
-
minus
-
dquote
-
squote
-
backQuote
-
underscore
-
qualifier
-
version
-
javaLowerCase
-
javaUpperCase
-
javaWhitespace
-
javaMirrored
-
javaJavaIdentifierStart
-
javaJavaIdentifierPart
-
javaId
-
fullyQualifiedName
-
startOfLine
-
endOfLine
-
wordBoundary
-
beginInput
-
endOfPreviousMatch
-
endOfInputForFinal
-
endOfInput
-
isLatin
-
inGreek
-
isAlphabetic
-
sc
-
-
Constructor Details
-
Catalog
public Catalog()
-
-
Method Details
-
named
If this class is extended, the named fields in that class can be used in named groups. This method will lookup the name of a field and create a capturing group with this name. It finds the field by comparing the content.- Parameters:
re- the RE that should be in a field in this class.- Returns:
- a group RE
-
control
Return a control char. For example, `control('b') returns ^b. See the sequence `\\cb`.- Parameters:
c- the control character- Returns:
- an RE representing the control character
-
g
-
or
-
or
Create an OR combination of a number of Strings. The strings are converted withlit(String).- Parameters:
res- the strings- Returns:
- the RE representing the OR
-
or
-
g
-
term
-
term
Seeterm(String,RE...)with a null for name- Parameters:
res- the members- Returns:
- a new
-
cc
-
lit
-
lit
-
quote
Use the quoting facility built intoPattern.quote(String)- Parameters:
s- the string- Returns:
- the quoted string
-
unicode
-
back
Used to reference a previous capturing group. Unfortunately this cannot be done by name. This class will by default create non-capturing groups, so only explicit groups need to be counted.- Parameters:
group- the group number- Returns:
- a new RE referencing a previous group
-
back
-
list
-
list
-
opt
-
opt
Return an optional literal (seelit(String)t- Parameters:
s- the literal- Returns:
- a Q representing the optional
-
some
-
set
-
not
Creates a regular expression that matches the negation of the provided regular expression. This method wraps the given regex pattern in a negative construct.- Parameters:
re- the regular expression to be negated- Returns:
- a new RE instance representing the negated version of the provided regular expression
-
reluctant
-
greedy
-
possesive
Modifies the given quantified regular expression to match in a possessive manner. A possessive quantifier does not give up matches as the regex engine backtracks.- Parameters:
re- the quantified regular expression to be modified- Returns:
- a new RE instance with a possessive quantification
-
anythingBut
Creates a regular expression that matches anything except the specified string. For a single character, it creates a negated character class; otherwise, it negates the literal string.- Parameters:
s- the string to be negated in the match- Returns:
- an RE instance that matches anything but the specified string
-
maybe
Creates a regular expression that optionally matches the given string. The string is wrapped in a non-capturing group with a quantifier allowing zero or one occurrence.- Parameters:
s- the string to be optionally matched- Returns:
- an RE instance that optionally matches the specified string
-
multiple
Creates a quantified regular expression that matches a specified minimum and maximum number of occurrences. This method applies a greedy quantifier.- Parameters:
minimum- the minimum number of occurrences to matchmaximum- the maximum number of occurrences to matchres- the regular expressions to be quantified- Returns:
- a Q instance representing the specified quantification
-
multiple
Creates a quantified regular expression that matches a specified minimum and maximum number of occurrences of a literal string. This method applies a greedy quantifier.- Parameters:
minimum- the minimum number of occurrences to matchmaximum- the maximum number of occurrences to matchlit- the literal string to be quantified- Returns:
- a Q instance representing the specified quantification of the literal string
-
atLeast
Creates a quantified regular expression that matches at least a specified minimum number of occurrences. This method applies a greedy quantifier.- Parameters:
minimum- the minimum number of occurrences to matchres- the regular expressions to be quantified- Returns:
- a Q instance representing the quantification with the specified minimum and no maximum limit
-
atLeast
Creates a quantified regular expression that matches at least a specified minimum number of occurrences of a literal string. This method applies a greedy quantifier.- Parameters:
minimum- the minimum number of occurrences to matchlit- the literal string to be quantified- Returns:
- a Q instance representing the quantification with the specified minimum and no maximum limit
-
caseInsenstive
Applies the case-insensitive flag to the provided regular expressions. This method makes the given patterns match characters regardless of their case.- Parameters:
res- the regular expressions to be affected by the case-insensitive flag- Returns:
- an F instance with the case-insensitive flag applied
-
caseInsenstiveOff
Turns off the case-insensitive flag for the provided regular expressions. This method reverts the given patterns to match characters considering their case.- Parameters:
res- the regular expressions to be affected by turning off the case-insensitive flag- Returns:
- an F instance with the case-insensitive flag turned off
-
dotall
Applies the dotall flag to the provided regular expressions. With this flag, the dot ('.') pattern matches any character, including a line terminator.- Parameters:
res- the regular expressions to be affected by the dotall flag- Returns:
- an F instance with the dotall flag applied
-
dotallOff
Turns off the dotall flag for the provided regular expressions. With the flag turned off, the dot ('.') pattern does not match line terminators by default.- Parameters:
res- the regular expressions to be affected by turning off the dotall flag- Returns:
- an F instance with the dotall flag turned off
-
comments
Applies the comments flag to the provided regular expressions. This flag allows whitespace and comments within the pattern for better readability.- Parameters:
res- the regular expressions to be affected by the comments flag- Returns:
- an F instance with the comments flag applied
-
commentsOff
Turns off the comments flag for the provided regular expressions. With the flag turned off, whitespace and comments within the pattern are no longer ignored.- Parameters:
res- the regular expressions to be affected by turning off the comments flag- Returns:
- an F instance with the comments flag turned off
-
multiline
Applies the multiline flag to the provided regular expressions. This flag changes the behavior of '^' and '$' from matching at the start and end of the input string to matching at the start and end of each line.- Parameters:
res- the regular expressions to be affected by the multiline flag- Returns:
- an F instance with the multiline flag applied
-
multilineOff
Turns off the multiline flag for the provided regular expressions. With the flag turned off, '^' and '$' match only at the start and end of the entire input string.- Parameters:
res- the regular expressions to be affected by turning off the multiline flag- Returns:
- an F instance with the multiline flag turned off
-
unicodeCharacterClass
Applies the unicode character class flag to the provided regular expressions. This flag enables the Unicode versions of predefined character classes and POSIX character classes.- Parameters:
res- the regular expressions to be affected by the unicode character class flag- Returns:
- an F instance with the unicode character class flag applied
-
unicodeCharacterClassOff
Turns off the unicode character class flag for the provided regular expressions. With the flag turned off, the ASCII versions of predefined character classes and POSIX character classes are used.- Parameters:
res- the regular expressions to be affected by turning off the unicode character class flag- Returns:
- an F instance with the unicode character class flag turned off
-
unicodeCase
Applies the unicode case flag to the provided regular expressions. This flag enables the correct handling of character cases in Unicode when applying case-insensitive matching.- Parameters:
res- the regular expressions to be affected by the unicode case flag- Returns:
- an F instance with the unicode case flag applied
-
unicodeCaseOff
Turns off the unicode case flag for the provided regular expressions. With the flag turned off, character cases in Unicode are not correctly handled when applying case-insensitive matching.- Parameters:
res- the regular expressions to be affected by turning off the unicode case flag- Returns:
- an F instance with the unicode case flag turned off
-
unixLines
Applies the unix lines flag to the provided regular expressions. This flag affects how line terminators are matched. With this flag, only the '\n' line terminator is recognized.- Parameters:
res- the regular expressions to be affected by the unix lines flag- Returns:
- an F instance with the unix lines flag applied
-
unixLinesOff
Turns off the unix lines flag for the provided regular expressions. With the flag turned off, line terminators are matched in a platform-independent manner.- Parameters:
res- the regular expressions to be affected by turning off the unix lines flag- Returns:
- an F instance with the unix lines flag turned off
-
atomic
-
atomic
Creates an atomic group with the provided string. An atomic group prevents the regex engine from backtracking once the group has matched.- Parameters:
string- the literal string to be included in the atomic group- Returns:
- a G instance representing an atomic group containing the provided string
-
ahead
Creates a lookahead group with the provided regular expressions. A lookahead group asserts that the given pattern must be matched next in the input sequence.- Parameters:
res- the regular expressions to be included in the lookahead group- Returns:
- a G instance representing a lookahead group containing the provided expressions
-
behind
Creates a lookbehind group with the provided regular expressions. A lookbehind group asserts that the given pattern must precede the current position in the input sequence.- Parameters:
res- the regular expressions to be included in the lookbehind group- Returns:
- a G instance representing a lookbehind group containing the provided expressions
-
seq
Creates a sequence of regular expressions. This method groups the provided expressions in the order they are given, without any additional logic.- Parameters:
res- the regular expressions to be sequenced- Returns:
- a G instance representing a sequence of the provided regular expressions
-
if_
Creates a conditional regular expression. The resulting pattern matches 'thenExpect' if 'condition' matches, otherwise it matches 'otherWiseExpect'.- Parameters:
condition- the conditional regular expressionthenExpect- the regular expression to match if the condition is trueotherWiseExpect- the regular expression to match if the condition is false- Returns:
- an RE instance representing the conditional regular expression
-
if_
Creates a conditional regular expression with no alternative case. The resulting pattern matches 'then' only if 'condition' matches.- Parameters:
condition- the conditional regular expressionthen- the regular expression to match if the condition is true- Returns:
- an RE instance representing the conditional regular expression with no alternative case
-
while_
Creates a regular expression that repeats the 'thenExpect' pattern as long as 'condition' matches.- Parameters:
condition- the condition for repetitionthenExpect- the regular expression to be repeated- Returns:
- an RE instance representing the repeated regular expression
-
until
Creates a regular expression that matches 'thenExpect' until 'condition' becomes true.- Parameters:
condition- the condition to terminate matchingthenExpect- the regular expression to match until the condition is met- Returns:
- an RE instance representing the regular expression matching until the condition
-
capture
Creates a capturing group with the provided regular expressions. This method groups the expressions and captures them for later reference.- Parameters:
res- the regular expressions to be included in the capturing group- Returns:
- a G instance representing a capturing group containing the provided expressions
-
string
Return a string that is delimeted on both sides with the same character. The character cannot be used directly but must be escaped with a backslash. -
re
-