Description Usage Arguments Value Examples
Test an atomic vector, list, or term list of regexes for validity.
1 | test_regex(regex, stringi = TRUE, ...)
|
regex |
An atomic vector, list, or term list of regexes to test for validity. |
stringi |
logical. If |
... |
ignored. |
Returns x back with warnings. Note that if a list is passed it is
coerced to a term_list
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ## Not run:
## atomic vector
test_regex(c('.', 'a')) ## works
test_regex(c('.', '(a')) ## warning
## list
test_regex(list(c('.', 'a'), 'd')) ## works
test_regex(list(c('.', 'a(('), 'd')) ## warning
discoure_markers <- list(
response_cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
back_channels = c("uh[- ]huh", "uhuh", "yeah"),
summons = "hey",
justification = "because"
)
trmlst_unnested <- read_term_list(term.list = discoure_markers, collapse = FALSE)
test_regex(trmlst_unnested) ## works
trmlst_unnested[[1]][1] <- 'bad1('
trmlst_unnested[[1]][3] <- 'bad2('
trmlst_unnested[[3]][1] <- 'bad3('
test_regex(trmlst_unnested) ## warning
trpl_list <- list(
list(
response_cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
back_channels = c("uh[- ]huh", "uhuh", "yeah"),
summons = "hey",
justification = "because"
),
list(summons ='the'),
list(summons = 'it', justification = 'ed\\s')
)
trmlst_nested <- read_term_list(term.list = trpl_list, collapse = FALSE)
test_regex(trmlst_nested) ## works
trmlst_nested[[1]][[1]][1] <- 'bad1('
trmlst_nested[[1]][[1]][3] <- 'bad2('
trmlst_nested[[1]][[3]][1] <- 'bad3('
trmlst_nested[[3]][[1]][1] <- 'bad4('
test_regex(trmlst_nested) ## warning
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.