Description Usage Arguments Details Value See Also Examples
A logical test of a regular expression's validity, extraction, removal, splitting results. These functions are useful for unit testing of regular expressions.
1 2 3 4 5 6 7 | test_extract(regex, input, output, stringi = FALSE)
test_remove(regex, input, output, stringi = FALSE)
test_split(regex, input, output, stringi = FALSE)
test_valid(regex, stringi = FALSE)
|
regex |
A regular expression to test. |
input |
The intput string(s) to extract/remove/split from. |
output |
The desired output of:
|
lofical. |
If |
These functions are inspired by Hadely Wickham's testthat
package. They can be used with testthat to test that regular
expressions are valid, extracting, removing, and splitting as expected. The
user may create their own tests and utilize all.equal
or
expect_equal
to ensure the expression is acting as
desired.
Returns the results of all.equal
for the
input
and desired output
.
all.equal
,
gsub
,
gregexpr
,
regmatches
,
test
1 2 3 4 5 6 7 8 | test_extract("\\w+", "I like candy.", list(c("I", "like", "candy")))
test_remove("^\\s+|\\s+$", " I like candy ", "I like candy")
test_split("(?<=[.?!])\\s+", "I see! When? Oh that's good.",
list(c("I see!", "When?", "Oh that's good.")))
test_valid("\\w+")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.