Class RegularExpression
java.lang.Object
com.flowingcode.vaadin.addons.regex.RegularExpression
Represents a regular expression.
This class assists in the creation and handling of regular expressions by providing pre-defined operators for common patterns such as "starts with", "ends with", and "contains". It also supports an advanced mode where users can input custom regular expressions.
Instances of this class are immutable and validated upon creation.
- Author:
- Javier Godoy
-
Constructor Summary
ConstructorsConstructorDescriptionRegularExpression(@NonNull RegularExpressionOperator operator, @NonNull String input) Creates a newRegularExpressionbased on the specifiedoperatorandinput. -
Method Summary
-
Constructor Details
-
RegularExpression
public RegularExpression(@NonNull @NonNull RegularExpressionOperator operator, @NonNull @NonNull String input) throws PatternSyntaxException Creates a newRegularExpressionbased on the specifiedoperatorandinput.- Parameters:
operator- the type of regular expression (e.g.,RegularExpressionOperator.CONTAINS)input- the string to be used for pattern creation- Throws:
PatternSyntaxException- if the resulting pattern is invalid.
-
-
Method Details
-
of
Creates aRegularExpressioninstance from a givenPattern.This method attempts to determine if the pattern corresponds to a simple
RegularExpressionOperatorlike "starts with", "ends with", or "contains". If it does, a correspondingRegularExpressionis returned. Otherwise, an advanced mode expression is created.- Parameters:
pattern- the pattern to analyze- Returns:
- a
RegularExpressioninstance - Throws:
NullPointerException- ifpatternisnull.
-
toString
-