Learn R Programming

testthat (version 0.3)

matches: Expectation: does string match regular expression?

Description

Expectation: does string match regular expression?

Usage

matches(regexp, all=TRUE)

Arguments

regexp
regular expression to test against
all
should all elements of actual value match regexp (TRUE), or does only one need to match (FALSE)

Details

If the object to be tested has length greater than one, all elements of the vector must match the pattern in order to pass.

See Also

str_detect for the function that powers the string matching

Examples

Run this code
expect_that("Testing is fun", matches("fun"))
expect_that("Testing is fun", matches("f.n"))
expect_match("Testing is fun", "f.n")

Run the code above in your browser using DataLab