Class RegexUtils
java.lang.Object
org.codehaus.mojo.versions.utils.RegexUtils
Utility methods to help with regex manipulation.
- Since:
- 1.0-alpha-3
- Author:
- Stephen Connolly
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertWildcardsToRegex(String wildcardRule, boolean exactMatch) Converts a wildcard rule to a regex rule.static intgetWildcardScore(String wildcardRule) Calculates a score for a wildcard rule.static StringTakes a string and returns the regex that will match that string exactly.
-
Field Details
-
REGEX_QUOTE_END
The end of a regex literal sequence.- Since:
- 1.0-alpha-1
- See Also:
-
REGEX_QUOTE_START
The start of a regex literal sequence.- Since:
- 1.0-alpha-1
- See Also:
-
REGEX_QUOTE_END_ESCAPED
-
-
Method Details
-
quote
-
getWildcardScore
Calculates a score for a wildcard rule. The score is calculated as follows:- each
?character adds 1 to the score - each
*character adds 1000 to the score
?) will have a lower score than those with less specific wildcards (i.e.*).- Parameters:
wildcardRule- the wildcard rule, may benull- Returns:
- the score
- each
-
convertWildcardsToRegex
Converts a wildcard rule to a regex rule.- Parameters:
wildcardRule- the wildcard rule, may benullexactMatch-trueresults in an regex that will match the entire string, whilefalsewill match the start of the string.- Returns:
- The regex rule.
-