fancy_regex library
Provides a different approach to write Regular Expressions.
This module exposes a single main class FancyRegex and a some classes implementing the interface RegExpComponent.
FancyRegex implements RegExp to enable the instances to interoperate with functions and methods that require Pattern or RegExp such as String.replaceAll.
The one small advantage of using FancyRegex is lowering the risk of typos when writing RegExps manually.
This module was created with the initial intention of introducing how RegExp works to beginners without having to work out directly reading symbols and patterns.
This module tries to adapt most known Regular Expression Operations, and most used ones as well. Rare usages, or insufficient validation strength while using the APIs here, will be addressed in future updates.
Bug Reports, Suggestions, and Issues, feel free to raise it directly at the package's Github Issues
Classes
- AlternationGroup
-
Expression that match one of multiple expressions provided, separated by
a vertical bar (
|
). - BackReference
- A reference to an existing Captured Group.
- BaseExpression
- CaptureGroup
- Capture a single, or a series of expressions and group them up as a single expression.
- CharacterClass
- Symbols that represent a group of character variants in Regular Expressions. Certain character class allows a negated form.
- CharacterGroup
-
Expression that contains a series of characters, or character ranges, that
matches if any character of the input matches element(s) of the group. Can
accept a caret (
^
) symbol as first element to apply a negated matching where it will instead match everything that is not within the group. - CharacterGroupRange
- Range definition used as filter in CharacterGroup class.
- FancyRegex
- Utility functionalities to write Regular Expressions with simpler terms.
- InputBoundary
- Allows matching the beginning and/or end of the expression input.
- LookAroundExpression
- Matcher that looks around the input without adding the additional matches to the result.
- MatchExactCount
- Matcher that checks if the expression has a match at least n times as specified by count parameter. Consecutive matches beyond are ignored.
- MatchOneOrMore
- Matcher that looks for existence of expression and returns a match it has at least one match, and includes any number of consecutive repetitions.
- MatchRangedCount
-
Matcher that checks if the expression has a match at least x times as
specified by start argument, count into as many repetition ahead as
possible, or until the repetition count reaches the y times as specified by
end argument, or returns earlier if isLazy set to
true
. - MatchZeroOrMore
- Matcher that looks for existence of expression and returns a match if exists and includes any number of consecutive repetitions.
- MatchZeroOrOne
- Matcher that looks for existence of expression and returns a match if exists and doesn't include any consecutive repetitions.
- NamedBackReference
- A reference to an existing Captured Group.
- Quantifier
- Matcher that repeats and counts the provided expression and returns a match if the calculation/lookup result satisfy the condition(s).
- RawExpression
- Class to represents literal String as RegExpComponent.
- RegExpComponent
-
Base interface for
FancyRegex
's expression block building. - SerialExpressions
- Container to group together multiple expressions in a linear left-to-right order without any separator.
- UnicodeEscape
- Matcher that matches characters based on their Unicode properties.
- WordBound
- Allows matching expression that is not preceded/followed by a alphanumeric. A negated variant will match the other way around.
- WordBoundary
- Insertable RegExpComponent to represents Word Boundary matching component
Extensions
Constants
-
regExpSpecialCharacters
→ const List<
String> - List of known special characters used as Regular Expression operator