Package org.apereo.cas.util
Class RegexUtils
- java.lang.Object
-
- org.apereo.cas.util.RegexUtils
-
public class RegexUtils extends java.lang.ObjectUtility class to assist with regex operations.- Since:
- 5.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternMATCH_NOTHING_PATTERNA pattern match that does not match anything.
-
Constructor Summary
Constructors Constructor Description RegexUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.regex.Patternconcatenate(java.util.Collection<?> requiredValues, boolean caseInsensitive)Concatenate all elements in the given collection to form a regex pattern.static java.util.regex.PatterncreatePattern(java.lang.String pattern)Creates the pattern.static java.util.regex.PatterncreatePattern(java.lang.String pattern, int flags)Creates the pattern with the given flags.static booleanfind(java.lang.String pattern, java.lang.String string)Attempts to find the next sub-sequence of the input sequence that matches the pattern.static booleanfind(java.util.regex.Pattern pattern, java.lang.String string)Attempts to find the next sub-sequence of the input sequence that matches the pattern.static booleanisValidRegex(java.lang.String pattern)Check to see if the specified pattern is a valid regular expression.static booleanmatches(java.util.regex.Pattern pattern, java.lang.String string)Matches the entire region for the string.static booleanmatches(java.util.regex.Pattern pattern, java.lang.String value, boolean completeMatch)Matches boolean.
-
-
-
Method Detail
-
isValidRegex
public static boolean isValidRegex(java.lang.String pattern)
Check to see if the specified pattern is a valid regular expression.- Parameters:
pattern- the pattern- Returns:
- whether this is a valid regex or not
-
concatenate
public static java.util.regex.Pattern concatenate(java.util.Collection<?> requiredValues, boolean caseInsensitive)Concatenate all elements in the given collection to form a regex pattern.- Parameters:
requiredValues- the required valuescaseInsensitive- the case insensitive- Returns:
- the pattern
-
createPattern
public static java.util.regex.Pattern createPattern(java.lang.String pattern)
Creates the pattern. Matching is by default case insensitive.- Parameters:
pattern- the pattern, may not be null.- Returns:
- the pattern or or
MATCH_NOTHING_PATTERNif pattern is null or invalid.
-
createPattern
public static java.util.regex.Pattern createPattern(java.lang.String pattern, int flags)Creates the pattern with the given flags.- Parameters:
pattern- the pattern, may be null.flags- the flags- Returns:
- the compiled pattern or
MATCH_NOTHING_PATTERNif pattern is null or invalid.
-
matches
public static boolean matches(java.util.regex.Pattern pattern, java.lang.String string)Matches the entire region for the string.- Parameters:
pattern- the patternstring- the string- Returns:
- true/false
- See Also:
Matcher.matches()
-
matches
public static boolean matches(java.util.regex.Pattern pattern, java.lang.String value, boolean completeMatch)Matches boolean.- Parameters:
pattern- the patternvalue- the valuecompleteMatch- the complete match- Returns:
- true/false
-
find
public static boolean find(java.util.regex.Pattern pattern, java.lang.String string)Attempts to find the next sub-sequence of the input sequence that matches the pattern.- Parameters:
pattern- the patternstring- the string- Returns:
- true/false
- See Also:
Matcher.find()
-
find
public static boolean find(java.lang.String pattern, java.lang.String string)Attempts to find the next sub-sequence of the input sequence that matches the pattern.- Parameters:
pattern- the patternstring- the string- Returns:
- true/false
-
-