/** SQL {@code SIMILAR} function with escape. */ public static boolean similar(String s, String pattern, String escape) { final String regex = Like.sqlToRegexSimilar(pattern, escape); return Pattern.matches(regex, s); }
/** SQL {@code SIMILAR} function. */ public static boolean similar(String s, String pattern) { final String regex = Like.sqlToRegexSimilar(pattern, null); return Pattern.matches(regex, s); }
/** SQL {@code SIMILAR} function. */ public static boolean similar(String s, String pattern) { final String regex = Like.sqlToRegexSimilar(pattern, null); return Pattern.matches(regex, s); }
/** SQL {@code SIMILAR} function. */ public static boolean similar(String s, String pattern) { final String regex = Like.sqlToRegexSimilar(pattern, null); return Pattern.matches(regex, s); }
/** SQL {@code SIMILAR} function with escape. */ public static boolean similar(String s, String pattern, String escape) { final String regex = Like.sqlToRegexSimilar(pattern, escape); return Pattern.matches(regex, s); }
/** SQL {@code SIMILAR} function with escape. */ public static boolean similar(String s, String pattern, String escape) { final String regex = Like.sqlToRegexSimilar(pattern, escape); return Pattern.matches(regex, s); }
/** * Translates a SQL SIMILAR pattern to Java regex pattern, with optional * escape string. */ static String sqlToRegexSimilar( String sqlPattern, CharSequence escapeStr) { final char escapeChar; if (escapeStr != null) { if (escapeStr.length() != 1) { throw invalidEscapeCharacter(escapeStr.toString()); } escapeChar = escapeStr.charAt(0); } else { escapeChar = 0; } return sqlToRegexSimilar(sqlPattern, escapeChar); }
/** * Translates a SQL SIMILAR pattern to Java regex pattern, with optional * escape string. */ static String sqlToRegexSimilar( String sqlPattern, CharSequence escapeStr) { final char escapeChar; if (escapeStr != null) { if (escapeStr.length() != 1) { throw invalidEscapeCharacter(escapeStr.toString()); } escapeChar = escapeStr.charAt(0); } else { escapeChar = 0; } return sqlToRegexSimilar(sqlPattern, escapeChar); }