/** * Verifies that the actual {@code CharSequence} matches the given regular expression pattern. * * <p>Example : * * <pre> * // assertion will pass * assertThat("Frodo").matches(Pattern.compile("..o.o")); * * // assertion will fail * assertThat("Frodo").matches(Pattern.compile(".*d")); * </pre> * * @param pattern the regular expression to which the actual {@code CharSequence} is to be * matched. * @return {@code this} assertion object. * @throws NullPointerException if the given pattern is {@code null}. * @throws AssertionError if the actual {@code CharSequence} is {@code null}. * @throws AssertionError if the actual {@code CharSequence} does not match the given regular * expression. */ public S matches(Pattern pattern) { strings.assertMatches(info, actual, pattern); return myself; }
/** * Verifies that the actual {@code CharSequence} matches the given regular expression. * * <p>Example : * * <pre> * // assertion will pass * assertThat("Frodo").matches("..o.o"); * * // assertion will fail * assertThat("Frodo").matches(".*d"); * </pre> * * @param regex the regular expression to which the actual {@code CharSequence} is to be matched. * @return {@code this} assertion object. * @throws NullPointerException if the given pattern is {@code null}. * @throws PatternSyntaxException if the regular expression's syntax is invalid. * @throws AssertionError if the actual {@code CharSequence} is {@code null}. * @throws AssertionError if the actual {@code CharSequence} does not match the given regular * expression. */ public S matches(CharSequence regex) { strings.assertMatches(info, actual, regex); return myself; }