The list of methods to do Regex Create are organized into topic(s).
String
toRegex(String includes) to Regex
return includes == null ? ".*" : includes.replace(".", "/").replace("*", ".*");
String
toRegEx(String input) Convert the incoming string to a regular expression.
return input.replace(".", "\\.").replace("*", ".*");
String
toRegex(String name) Computes the regular expression corresponding to a package or class name, by escaping dots.
return name.replace(STRING_DOT, REGEX_DOT);
String
toRegex(String param) Convert the string into a regex to allow easy matching.
StringBuffer regex = new StringBuffer();
for (int i = 0; i < param.length(); i++) {
char next = param.charAt(i);
if ('*' == next)
regex.append(".+");
else if ('?' == next)
regex.append(".");
else if ('.' == next)
...
String
toRegex(String wildcard) convert wild card to regular expression
String converted = "^" + wildcard.replaceAll("(^|/)\\*\\*/", "@@").replaceAll("(^|/)\\*\\*", "@@")
.replaceAll("\\.", "\\\\.").replaceAll("\\*", "[^/]*").replaceAll("\\?", ".");
if (converted.contains("@@")) {
converted = converted.replaceAll("@@", "(.*/)?") + "((^|/).*)?$";
return converted;
String
toRegExFormat(String pattern) Converts wildcard format ('*' and '?') to reg-ex format.
StringBuffer regex = new StringBuffer(pattern.length());
boolean escaped = false;
boolean quoting = false;
for (int i = 0; i < pattern.length(); i++) {
char c = pattern.charAt(i);
if (c == '*' && !escaped) {
if (quoting) {
regex.append("\\E");
...
String
toRegexPattern(String filter) Convert
filter to a regular expression
StringBuffer pattern = new StringBuffer(".*");
boolean isWaitingForEndQuote = false;
for (int i = 0; i < filter.length(); i++) {
char c = filter.charAt(i);
if (c == '*' || c == '?') {
if (isWaitingForEndQuote) {
pattern.append("\\E");
isWaitingForEndQuote = false;
...
String
toRegexPattern(String pattern) Converts a pattern string with '*' and '?'
int patternLength = pattern.length();
StringBuffer result = new StringBuffer(patternLength);
boolean escaped = false;
boolean quoting = false;
for (int i = 0; i < patternLength; i++) {
char ch = pattern.charAt(i);
switch (ch) {
case '*': {
...