expect_match {tinytest}R Documentation

Match strings to a regular expression

Description

Results in TRUE only when all elements of current match the regular expression in pattern. Matching is done by grepl.

Usage

expect_match(current, pattern, info = NA_character_, ...)

Arguments

current

[character] String(s) to check for pattern.

pattern

[character] A regular expression.

info

[character] scalar. Optional user-defined message. Must be a single character string. Multiline comments may be separated by "\n".

...

passed to grepl

See Also

Other test-functions: expect_equal_to_reference(), expect_equal(), expect_length(), ignore()

Examples

expect_match("hello world", "world")                    # TRUE
expect_match("hello world", "^world$")                  # FALSE
expect_match("HelLO woRlD", "world", ignore.case=TRUE)  # TRUE
expect_match(c("apple","banana"), "a")                  # TRUE
expect_match(c("apple","banana"), "b")                  # FALSE


[Package tinytest version 1.4.1 Index]