val_matches: Test that the user's expression matches a regular expression.

Description Usage Arguments Value See Also Examples

View source: R/answerTests2.R

Description

Returns TRUE if as.character(e$val) matches the regular expression given as the first argument.

Usage

1
val_matches(regular_expression)

Arguments

regular_expression

a regular expression which user value should match

Value

TRUE or FALSE

See Also

Other AnswerTests: AnswerTests, any_of_exprs(), calculates_same_value(), expr_creates_var(), expr_identical_to(), expr_is_a(), expr_uses_func(), func_of_newvar_equals(), omnitest(), val_has_length(), var_is_a()

Examples

1
2
3
4
5
6
7
8
## Not run: 
  # Test that a user has entered a value matching
  # '[Cc]ollege [Ss]tudents' or has selected it 
  # in a multiple choice question.
  #
  val_matches('[Cc]ollege [Ss]tudents')

## End(Not run)

swirl documentation built on Jan. 16, 2020, 5:03 p.m.