/** * Coerce a Matcher instance to a boolean value. * * @param matcher the matcher * @return the boolean value * @since 1.7.0 */ public static boolean asBoolean(Matcher matcher) { if (null == matcher) { return false; } RegexSupport.setLastMatcher(matcher); return matcher.find(); }
/** * 'Case' implementation for the {@link java.util.regex.Pattern} class, which allows * testing a String against a number of regular expressions. * For example: * <pre>switch( str ) { * case ~/one/ : * // the regex 'one' matches the value of str * } * </pre> * Note that this returns true for the case where both the pattern and * the 'switch' values are <code>null</code>. * * @param caseValue the case value * @param switchValue the switch value * @return true if the switchValue is deemed to match the caseValue * @since 1.0 */ public static boolean isCase(Pattern caseValue, Object switchValue) { if (switchValue == null) { return caseValue == null; } final Matcher matcher = caseValue.matcher(switchValue.toString()); if (matcher.matches()) { RegexSupport.setLastMatcher(matcher); return true; } else { return false; } }
/** * Find the right hand regex within the left hand string and return a matcher. * * @param left string to compare * @param right regular expression to compare the string to */ public static boolean matchRegex(Object left, Object right) { if (left == null || right == null) return false; Pattern pattern; if (right instanceof Pattern) { pattern = (Pattern) right; } else { pattern = Pattern.compile(toString(right)); } String stringToCompare = toString(left); Matcher matcher = pattern.matcher(stringToCompare); RegexSupport.setLastMatcher(matcher); return matcher.matches(); }
/** * Coerce a Matcher instance to a boolean value. * * @param matcher the matcher * @return the boolean value * @since 1.7.0 */ public static boolean asBoolean(Matcher matcher) { RegexSupport.setLastMatcher(matcher); return matcher.find(); }
/** * 'Case' implementation for the {@link java.util.regex.Pattern} class, which allows * testing a String against a number of regular expressions. * For example: * <pre>switch( str ) { * case ~/one/ : * // the regex 'one' matches the value of str * } * </pre> * Note that this returns true for the case where both the pattern and * the 'switch' values are <code>null</code>. * * @param caseValue the case value * @param switchValue the switch value * @return true if the switchValue is deemed to match the caseValue * @since 1.0 */ public static boolean isCase(Pattern caseValue, Object switchValue) { if (switchValue == null) { return caseValue == null; } final Matcher matcher = caseValue.matcher(switchValue.toString()); if (matcher.matches()) { RegexSupport.setLastMatcher(matcher); return true; } else { return false; } }
/** * 'Case' implementation for the {@link Pattern} class, which allows * testing a String against a number of regular expressions. * For example: * <pre>switch( str ) { * case ~/one/ : * // the regex 'one' matches the value of str * } * </pre> * Note that this returns true for the case where both the pattern and * the 'switch' values are <code>null</code>. * * @param caseValue the case value * @param switchValue the switch value * @return true if the switchValue is deemed to match the caseValue */ public static boolean isCase(Pattern caseValue, Object switchValue) { if (switchValue == null) { return caseValue == null; } final Matcher matcher = caseValue.matcher(switchValue.toString()); if (matcher.matches()) { RegexSupport.setLastMatcher(matcher); return true; } else { return false; } }
/** * 'Case' implementation for the {@link Pattern} class, which allows * testing a String against a number of regular expressions. * For example: * <pre>switch( str ) { * case ~/one/ : * // the regex 'one' matches the value of str * } * </pre> * Note that this returns true for the case where both the pattern and * the 'switch' values are <code>null</code>. * * @param caseValue the case value * @param switchValue the switch value * @return true if the switchValue is deemed to match the caseValue * @since 1.0 */ public static boolean isCase(Pattern caseValue, Object switchValue) { if (switchValue == null) { return caseValue == null; } final Matcher matcher = caseValue.matcher(switchValue.toString()); if (matcher.matches()) { RegexSupport.setLastMatcher(matcher); return true; } else { return false; } }
/** * 'Case' implementation for the {@link Pattern} class, which allows * testing a String against a number of regular expressions. * For example: * <pre>switch( str ) { * case ~/one/ : * // the regex 'one' matches the value of str * } * </pre> * Note that this returns true for the case where both the pattern and * the 'switch' values are <code>null</code>. * * @param caseValue the case value * @param switchValue the switch value * @return true if the switchValue is deemed to match the caseValue * @since 1.0 */ public static boolean isCase(Pattern caseValue, Object switchValue) { if (switchValue == null) { return caseValue == null; } final Matcher matcher = caseValue.matcher(switchValue.toString()); if (matcher.matches()) { RegexSupport.setLastMatcher(matcher); return true; } else { return false; } }
/** * Find the right hand regex within the left hand string and return a matcher. * * @param left string to compare * @param right regular expression to compare the string to */ public static boolean matchRegex(Object left, Object right) { Pattern pattern; if (right instanceof Pattern) { pattern = (Pattern) right; } else { pattern = Pattern.compile(toString(right)); } String stringToCompare = toString(left); Matcher matcher = pattern.matcher(stringToCompare); RegexSupport.setLastMatcher(matcher); return matcher.matches(); }
/** * Find the right hand regex within the left hand string and return a matcher. * * @param left string to compare * @param right regular expression to compare the string to */ public static boolean matchRegex(Object left, Object right) { Pattern pattern; if (right instanceof Pattern) { pattern = (Pattern) right; } else { pattern = Pattern.compile(toString(right)); } String stringToCompare = toString(left); Matcher matcher = pattern.matcher(stringToCompare); RegexSupport.setLastMatcher(matcher); return matcher.matches(); }
RegexSupport.setLastMatcher(matcher); return matcher.find();
/** * Find the right hand regex within the left hand string and return a matcher. * * @param left string to compare * @param right regular expression to compare the string to */ public static boolean matchRegex(Object left, Object right) { if (left == null || right == null) return false; Pattern pattern; if (right instanceof Pattern) { pattern = (Pattern) right; } else { pattern = Pattern.compile(toString(right)); } String stringToCompare = toString(left); Matcher matcher = pattern.matcher(stringToCompare); RegexSupport.setLastMatcher(matcher); return matcher.matches(); }
/** * Find the right hand regex within the left hand string and return a matcher. * * @param left string to compare * @param right regular expression to compare the string to */ public static boolean matchRegex(Object left, Object right) { if(left == null || right == null) return false; Pattern pattern; if (right instanceof Pattern) { pattern = (Pattern) right; } else { pattern = Pattern.compile(toString(right)); } String stringToCompare = toString(left); Matcher matcher = pattern.matcher(stringToCompare); RegexSupport.setLastMatcher(matcher); return matcher.matches(); }
RegexSupport.setLastMatcher(matcher); return matcher.find();
RegexSupport.setLastMatcher(matcher); return matcher.find();