Package dev.yasint.regexsynth.ast
Class RegexSet
java.lang.Object
dev.yasint.regexsynth.ast.RegexSet
- All Implemented Interfaces:
Expression
public final class RegexSet extends java.lang.Object implements Expression
Synthesis :: Regular Expression Set
This generates a regular expression set when given a range or chars. This class handles the simple character class and ranged character classes expressions along with set negation.
-
Method Summary
Modifier and Type Method Description RegexSetdifference(RegexSet b)Performs a subtraction of two regular expressions set.RegexSetintersection(RegexSet b)Performs a intersection of two regular expressions set.java.lang.StringBuildertoRegex()Creates a character class expression.RegexSetunion(RegexSet b)Performs a union of two regular expressions set.RegexSetwithUnicodeClass(UnicodeScript block, boolean negated)This allows you to include unicode blocks to a set expression.
-
Method Details
-
union
Performs a union of two regular expressions set. It will modify the source set @code{this} while operating.- Parameters:
b- set expression b- Returns:
- elements that belongs to this or b
-
intersection
Performs a intersection of two regular expressions set. It will modify the source set @code{this} while operating.- Parameters:
b- set expression b- Returns:
- elements that belongs to this and b
-
difference
Performs a subtraction of two regular expressions set. It will modify the source set @code{this} while operating.- Parameters:
b- set expression b- Returns:
- elements that belongs to this and not to b
-
withUnicodeClass
This allows you to include unicode blocks to a set expression. Note that when a block is included to a set. It does not check for ranges, it simply append the correct syntax to the set expression. i.e. [0-9A-Z\p{Arabic}]- Parameters:
negated- whether this unicode block is negated or notblock- valid unicode general category / script block- Returns:
- this
-
toRegex
public java.lang.StringBuilder toRegex()Creates a character class expression. This algorithm uses unicode codepoints to create character class ranges.- Specified by:
toRegexin interfaceExpression- Returns:
- set expression
-