Package org.rekex.regexp
Class RegExpApi
java.lang.Object
org.rekex.regexp.RegExpApi
This class contains static factory methods to create and transform regular expressions,
using data structure of
RegExp.
For convenience, many methods, like seq(Object...), accept `Object` as arguments,
which are automatically converted to `RegExp`.
`Character` or `Integer` is converted to a single character.
`String` is converted to a sequence of single characters.
In addition, some methods, like intersect(Object...), expect arguments to be character classes;
automatic conversion will be attempted, e.g. to convert `alt(cc1,cc2)` to `union(cc1,cc2)`,
and `seq(cc1)` to `cc1`.
For opt(Object...), rep0(Object...), rep1(Object...),
multiple arguments will be interpreted as a sequence,
e.g. `opt(r1, r2)` is equivalent to `opt(seq(r1, r2))`.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RegExpAlternation of subexpressions.static RegExp.AtomicGroupatomicGroup(RegExp arg) An atomic groupbackRef(int number) Back reference with a group numberBack reference with a group namebackRef(RegExp.Group.Named namedGroup) Back reference to a named groupstatic RegExp.BoundaryA boundary matcher, e.g.static RegExp.BoundarySame as `boundary("\\A")`static RegExp.BoundarySame as `boundary("^")`static RegExp.BoundarySame as `boundary("\\z")`static RegExp.BoundarySame as `boundary("\\Z")`static RegExp.BoundarySame as `boundary("$")`static RegExp.BoundarySame as `boundary("\\G")`static RegExp.BoundarySame as `boundary("\\B")`static RegExp.BoundarySame as `boundary("\\b")`static RegExp.CharClassA character class that contains all code points in `chars`.static intfindGroupNumberIn(RegExp.Group group, RegExp exp) Find the group number of `group` in `exp`; return -1 if not found.static RegExp.FlaggedTurn flags on/offstatic RegExp.Group.NamedA named groupstatic RegExp.Group.UnnamedAn un-named groupstatic RegExp.FlaggedignoreCase(RegExp arg) Turn on the flag CASE_INSENSITIVEstatic RegExp.CharClassIntersection of character classes.static RegExp.LookaroundA lookahead, positive or negativestatic RegExp.Lookaroundlookbehind(boolean positive, RegExp arg) A lookbehind, positive or negativestatic RegExp.CharClassNegation of a character classes.static RegExp.OpaqueAn opaque regexstatic RegExp.QuantifiedOptional, i.e.static RegExp.QuantifiedPossessive quantifierstatic RegExp.CharClass.Predefinedpredefined(String regex) A predefined character class, e.g.static RegExp.CharClass.Rangerange(int from, int to) A character class with characters in [from-to], inclusive.static RegExp.QuantifiedReluctant quantifierstatic RegExp.QuantifiedRepeat 0 or more times, i.e.static RegExp.QuantifiedRepeat 1 or more times, i.e.static RegExpConcatenation of subexpressions.static RegExpPerform some simplifications to the regular expressionstatic RegExp.QuantifiedRepeat `min` to `max` times, inclusive.static RegExp.QuantifiedRepeat exactly `n` timesstatic StringReturn the typical string representation of the regular expression.static StringtoTreeText(RegExp exp) Return a multiline text that displays the tree structure of the regular expression.static RegExp.CharClassUnion of character classes.
-
Constructor Details
-
RegExpApi
public RegExpApi()
-
-
Method Details
-
ch
A character class that contains all code points in `chars`. -
range
A character class with characters in [from-to], inclusive. -
predefined
A predefined character class, e.g. `predefined("\\d")`. -
union
Union of character classes. Each `arg` must be convertible to a character class. -
intersect
Intersection of character classes. Each `arg` must be convertible to a character class. -
negate
Negation of a character classes. The `arg` must be convertible to a character class. -
seq
Concatenation of subexpressions. -
alt
Alternation of subexpressions. -
opt
Optional, i.e. X? -
rep0
Repeat 0 or more times, i.e. X* -
rep1
Repeat 1 or more times, i.e. X+ -
times
Repeat exactly `n` times -
times
Repeat `min` to `max` times, inclusive. Set `max=Long.MAX_VALUE` as infinity. -
reluctant
Reluctant quantifier -
possessive
Possessive quantifier -
group
An un-named group -
group
A named group -
atomicGroup
An atomic group -
backRef
Back reference with a group name -
backRef
Back reference to a named group -
backRef
Back reference with a group number -
flag
Turn flags on/off -
ignoreCase
Turn on the flag CASE_INSENSITIVE -
boundary
A boundary matcher, e.g. `boundary("\\b{g}")`. -
boundary_beginning_of_line
Same as `boundary("^")` -
boundary_end_of_line
Same as `boundary("$")` -
boundary_word_boundary
Same as `boundary("\\b")` -
boundary_non_word_boundary
Same as `boundary("\\B")` -
boundary_beginning_of_input
Same as `boundary("\\A")` -
boundary_end_of_previous_match
Same as `boundary("\\G")` -
boundary_end_of_input_but_for_final_terminator
Same as `boundary("\\Z")` -
boundary_end_of_input
Same as `boundary("\\z")` -
lookahead
A lookahead, positive or negative -
lookbehind
A lookbehind, positive or negative -
opaque
An opaque regex -
simplify
Perform some simplifications to the regular expression -
toRegex
Return the typical string representation of the regular expression. -
toTreeText
Return a multiline text that displays the tree structure of the regular expression. -
findGroupNumberIn
Find the group number of `group` in `exp`; return -1 if not found.
-