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

regexPatterns

fun regexPatterns(pattern: String, vararg otherPatterns: String): RegexPatterns (source)

Helper function to create a RegexPatterns based on the given pattern and otherPatterns -- allows expressing String, vararg String which are treated as regex patterns.

// all regex patterns match
expect("ABC") toContain regexPatterns("A(B)?", "(B)?C")

// holds because `toContain regexPatterns(...)` does not search for unique matches
// use `toContain exactly 2 regex "A(B)?"` to check if the subject contains the regex two times
expect("ABC") toContain regexPatterns("A(B)?", "A(B)?")

fails { // because second regex doesn't match
    expect("ABC") toContain regexPatterns("A", "X")
}