Class RegularExpressionUtils
java.lang.Object
fr.paris.lutece.plugins.genericattributes.util.RegularExpressionUtils
Matches a value typed by a user against a regular expression written by an administrator. The value comes from the front office, the expression may
backtrack catastrophically: the matching is bounded in time and in length, so that a crafted answer cannot hold a server thread.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe result of a match -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetSyntaxError(String strRegex) Check that an expression compilesMatch the whole value against the expression, within the time and length limits set by the propertiesMatch the whole value against the expression
-
Method Details
-
getSyntaxError
Check that an expression compiles- Parameters:
strRegex- the expression- Returns:
- the description of the syntax error, or null if the expression is valid
-
matches
Match the whole value against the expression, within the time and length limits set by the properties- Parameters:
strRegex- the expressionstrValue- the value- Returns:
- the result of the match
-
matches
public static RegularExpressionUtils.MatchResult matches(String strRegex, String strValue, long nTimeoutMs, int nMaxLength) Match the whole value against the expression- Parameters:
strRegex- the expressionstrValue- the valuenTimeoutMs- the time limit of the matching, in millisecondsnMaxLength- the longest value evaluated- Returns:
- the result of the match
-