public class RegexpUtils extends Object
| Constructor and Description |
|---|
RegexpUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
replaceAll(String str,
String regex,
String replacement)
Equivalent of JDK 1.4's
String.replaceAll(String regex, String replacement), usable in JDK 1.3 |
static String |
wildcardToRegex(String wildcard)
Convert a wildcard to a java.util.regexp (ie
'*' becomes '.*' and '?' becomes '.'). |
public static String replaceAll(String str, String regex, String replacement)
String.replaceAll(String regex, String replacement), usable in JDK 1.3str - The string to apply operations toregex - The regex that str should matchreplacement - String to replace matched string with (using $1, $2 etc for substitutions).public static String wildcardToRegex(String wildcard)
'*' 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
wildcard - A wildcard which can contain '*' and '?' charactersCopyright © 2002-2017 Atlassian. All Rights Reserved.