The list of methods to do Wildcard are organized into topic(s).
String
wildCard(final String _name) This method appends wild cards before and after a string./
String trimmedName = _name.toString().trim();
if (trimmedName == null || trimmedName.equals("") || trimmedName.length() == 0) {
return "";
if (trimmedName.length() > 0 && !trimmedName.endsWith("%")) {
trimmedName = trimmedName + "%";
if (trimmedName.length() > 0 && !trimmedName.startsWith("%")) {
...
String
wildCard(String _name) wild Card
String trimmedName = _name.toString().trim();
if (trimmedName == null || trimmedName.equals("") || trimmedName.length() == 0) {
return "";
} else if (trimmedName.length() > 0 && !trimmedName.endsWith("%")) {
return trimmedName + "%";
} else {
return trimmedName;
int
wildcardCompare(String s, String z) wildcard Compare
if (s.equals("*") || z.equals("*")) {
return 0;
int l = s.length();
int m = z.length();
int i = 0;
int j = 0;
while (j < m && i < l) {
...
String
wildcardCriterionSQL(final String query) Replaces the query with the wildcards asterisk "*" and interrogation mark "?"
String newQuery = query.replace('*', '%').replace('?', '_');
return newQuery;
String
wildcardOrIsNullIfEmpty(String column, String inString) wildcard Or Is Null If Empty
StringBuilder sb = new StringBuilder();
if ((inString == null) || (inString.equalsIgnoreCase(""))) {
sb.append("'%' or ").append(column).append(" is null");
return sb.toString();
sb.append("'").append(inString).append("'");
return sb.toString();
String
wildcardSearchToRegex(final String wildcard) wildcard Search To Regex
StringBuilder buffer = new StringBuilder(wildcard.length() + 2);
buffer.append('^');
for (char c : wildcard.toCharArray()) {
if (c == '*') {
buffer.append(".*");
} else if (c == '?') {
buffer.append('.');
} else if ("+()^$.{}[]|\\".indexOf(c) != -1) {
...
String
wildcardSqlToUser(String exp) Convert an SQL LIKE/NOT LIKE expression to a * wildcard expression.
StringBuffer sb = new StringBuffer();
for (int i = 0; i < exp.length(); i++) {
String substring = exp.substring(i);
if (substring.startsWith("%")) {
sb.append("*");
} else {
if (substring.startsWith("_")) {
sb.append("?");
...
String
wildCardsToX(String s) Replaces all '*' and '?'
if (s == null || s.isEmpty())
return s;
StringBuilder res = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLetterOrDigit(ch) || ch == '-' || ch == '.') {
} else if (ch == '*' || ch == '?') {
ch = 'x';
...