Package com.atlassian.jira.util
Class RegexpUtils
java.lang.Object
com.atlassian.jira.util.RegexpUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
replaceAll
(String str, String regex, String replacement) Equivalent of JDK 1.4'sString.replaceAll(String regex, String replacement)
, usable in JDK 1.3static String
wildcardToRegex
(String wildcard) Convert a wildcard to a java.util.regexp (ie'*'
becomes'.*'
and'?'
becomes'.'
).static String
wildcardToRegex
(String wildcard, boolean exactMatchRequired) Convert a wildcard to a java.util.regexp (ie'*'
becomes'.*'
and'?'
becomes'.'
).
-
Constructor Details
-
RegexpUtils
public RegexpUtils()
-
-
Method Details
-
replaceAll
Equivalent of JDK 1.4'sString.replaceAll(String regex, String replacement)
, usable in JDK 1.3- Parameters:
str
- The string to apply operations toregex
- The regex that str should matchreplacement
- String to replace matched string with (using $1, $2 etc for substitutions).- Returns:
- A modified version of str, or null if the regexp was invalid
-
wildcardToRegex
Convert a wildcard to a java.util.regexp (ie'*'
becomes'.*'
and'?'
becomes'.'
).Note that this converts wildcards to an exact match, so searching for
'a'
becomes'^a$'
.Copied from http://www.rgagnon.com/javadetails/java-0515.html
- Parameters:
wildcard
- A wildcard which can contain'*'
and'?'
characters- Returns:
- A regular expression that can be passed to java.util.regexp
-
wildcardToRegex
Convert a wildcard to a java.util.regexp (ie'*'
becomes'.*'
and'?'
becomes'.'
).Note if second parameter is true the wildcard will be converted to an exact match, so searching for
'a'
will become'^a$'
.- Parameters:
wildcard
- A wildcard which can contain'*'
and'?'
charactersexactMatchRequired
- A flag indicating if exact match is required- Returns:
- A regular expression that can be passed to java.util.regexp
-