Package dev.yasint.regexsynth.dsl
Class CharClasses
java.lang.Object
dev.yasint.regexsynth.dsl.CharClasses
public final class CharClasses
extends java.lang.Object
Contains all the set constructs and character classes.
RegexSynth supports all the POSIX character classes.
- Since:
- 1.0.0
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCharClasses.EscapeSequencesEscape sequences.static classCharClasses.PosixPosix character classes. -
Constructor Summary
Constructors Constructor Description CharClasses() -
Method Summary
Modifier and Type Method Description static Expressionanything()Matches any character, possibly including newline \n if the 's'RegexSynth.FlagsDOTALL flag is turned on.static Expressiondifference(Expression setA, Expression setB)static ExpressionemptySet()Constructs an empty set.static ExpressionincludeUnicodeScript(Expression set, UnicodeScript script, boolean negated)static Expressionintersection(Expression setA, Expression setB)static Expressionnegated(Expression set)Simply converts a given set to a negated character class.static ExpressionrangedSet(int codepointA, int codepointB)Creates a ranged regex charclass.static ExpressionrangedSet(java.lang.String from, java.lang.String to)Creates a ranged regex charclass.static ExpressionsimpleSet(int... codepoints)static ExpressionsimpleSet(java.lang.String... characters)Creates a simple regex charclass i.e.static Expressionunion(Expression setA, Expression setB)Performs a union operation on two sets
-
Constructor Details
-
CharClasses
public CharClasses()
-
-
Method Details
-
anything
Matches any character, possibly including newline \n if the 's'RegexSynth.FlagsDOTALL flag is turned on.- Returns:
- match anything
-
negated
Simply converts a given set to a negated character class.[^acd]. This is a impure function. Because it mutates the source set.- Parameters:
set- source set to convert- Returns:
- negated set expression
-
union
Performs a union operation on two sets- Parameters:
setA- source setsetB- target set- Returns:
- result
-
difference
-
intersection
-
includeUnicodeScript
public static Expression includeUnicodeScript(Expression set, UnicodeScript script, boolean negated) -
rangedSet
Creates a ranged regex charclass. i.e. [A-Z]- Parameters:
from- staring char inclusive (surrogates or bmp)to- ending char inclusive (surrogates or bmp)- Returns:
- set expression
-
rangedSet
Creates a ranged regex charclass. i.e. [A-Z]- Parameters:
codepointA- staring codepoint inclusivecodepointB- ending codepoint inclusive- Returns:
- set expression
-
simpleSet
Creates a simple regex charclass i.e. [135] will be optimized if it's a valid range. for example: if you pass a,b,c,d,f it will create [a-df]. but if you pass elements like a,z then it will only create a set for those two element without ranges [az]- Parameters:
characters- characters (surrogates or bmp)- Returns:
- set expression
-
simpleSet
- Parameters:
codepoints- codepoints- Returns:
- set expression
-
emptySet
Constructs an empty set. This is useful when you only want to include unicode scripts into a set expression.- Returns:
- empty set expression
-