R: Expectation: does string match a regular expression?

expect_match {testthat} | R Documentation

## Expectation: does string match a regular expression?

### Description

Expectation: does string match a regular expression?

### Usage

    expect_match(object, regexp, perl = FALSE, fixed = FALSE, ..., all = TRUE,
      info = NULL, label = NULL)

### Arguments

`object` | object to test
`regexp` | Regular expression to test against.
`perl` | logical. Should Perl-compatible regexps be used?
`fixed` | logical. If `TRUE`, `pattern` is a string to be matched as is. Overrides all conflicting arguments.
`...` | Arguments passed on to `base::grepl` ignore.case if `FALSE`, the pattern matching is case sensitive and if `TRUE`, case is ignored during matching. useBytes logical. If `TRUE` the matching is done byte-by-byte rather than character-by-character. See ‘Details’.
`all` | Should all elements of actual value match `regexp` (TRUE), or does only one need to match (FALSE)
`info` | extra information to be included in the message (useful when writing tests in loops).
`label` | object label. When `NULL`, computed from deparsed object.

### See Also

Other expectations: `comparison-expectations`, `equality-expectations`, `expect_length`, `expect_named`, `inheritance-expectations`, `logical-expectations`, `output-expectations`

### Examples

    expect_match("Testing is fun", "fun")
    expect_match("Testing is fun", "f.n")

    ## Not run:
    expect_match("Testing is fun", "horrible")

    # Zero-length inputs always fail
    expect_match(character(), ".")

    ## End(Not run)

[Package testthat version 2.0.0 Index]