doc / ch.tutteli.atrium.api.infix.en_GB / toMatch

toMatch

infix fun <T : CharSequence> Expect<T>.toMatch(pattern: Regex): Expect<T> (source)

Expects that the subject of this expectation (a CharSequence) matches the given Regex.

In contrast to toContainRegex it does not look for a partial match but for an entire match.

expect("ABC") toMatch "A(B)?C".toRegex() // subject is fully matched

fails { // because subject isn't fully matched, use containsRegex for partial matching
    expect("ABC") toMatch "A".toRegex()
}

Return
an Expect for the subject of this expectation.

Since
0.17.0