Package org.codehaus.mojo.animal_sniffer
Class RegexUtils
- java.lang.Object
-
- org.codehaus.mojo.animal_sniffer.RegexUtils
-
public final class RegexUtils extends java.lang.Object
Utility methods to help with regex manipulation.- Since:
- 1.3
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REGEX_QUOTE_END
The end of a regex literal sequence.static java.lang.String
REGEX_QUOTE_END_ESCAPED
Escape the escapes.static java.lang.String
REGEX_QUOTE_START
The start of a regex literal sequence.
-
Constructor Summary
Constructors Modifier Constructor Description private
RegexUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.regex.Pattern
compileWildcard(java.lang.String wildcard)
Compiles a pattern matcher using wildcard based matching.static java.lang.String
convertWildcardsToRegex(java.lang.String wildcardRule, boolean exactMatch)
Converts a wildcard rule to a regex rule.static java.lang.String
quote(java.lang.String s)
Takes a string and returns the regex that will match that string exactly.
-
-
-
Field Detail
-
REGEX_QUOTE_END
public static final java.lang.String REGEX_QUOTE_END
The end of a regex literal sequence.- Since:
- 1.3
- See Also:
- Constant Field Values
-
REGEX_QUOTE_START
public static final java.lang.String REGEX_QUOTE_START
The start of a regex literal sequence.- Since:
- 1.3
- See Also:
- Constant Field Values
-
REGEX_QUOTE_END_ESCAPED
public static final java.lang.String REGEX_QUOTE_END_ESCAPED
Escape the escapes.- Since:
- 1.3
- See Also:
- Constant Field Values
-
-
Method Detail
-
quote
public static java.lang.String quote(java.lang.String s)
Takes a string and returns the regex that will match that string exactly.- Parameters:
s
- The string to match.- Returns:
- The regex that will match the string exactly.
- Since:
- 1.3
-
convertWildcardsToRegex
public static java.lang.String convertWildcardsToRegex(java.lang.String wildcardRule, boolean exactMatch)
Converts a wildcard rule to a regex rule.- Parameters:
wildcardRule
- the wildcard rule.exactMatch
-true
results in an regex that will match the entire string, whilefalse
will match the start of the string.- Returns:
- The regex rule.
-
compileWildcard
public static java.util.regex.Pattern compileWildcard(java.lang.String wildcard)
Compiles a pattern matcher using wildcard based matching.- Parameters:
wildcard
- The wildcards rule to match.- Returns:
- A pattern to match the supplied wildcards rule.
-
-