toMatch

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.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

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

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