knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(RVerbalExpressions)
The goal of this vignette is to provide some basic examples that solve common regular expression tasks. The print
and grepl
calls are attached at the end of each chain to show the regular expression that is constructed and what it matches.
# find something that must contain two words rx() %>% rx_find("cat") %>% rx_anything() %>% rx_find("dog") %>% print() %>% grepl(c("cat dog", "cat", "dog"))
# find something between two words rx() %>% rx_seek_prefix("cat") %>% rx_something() %>% rx_seek_suffix("dog") %>% print() %>% grepl(c("cat something dog", "catdog"), perl = TRUE)
# find something that starts with word rx() %>% rx_start_of_line() %>% rx_find("cat") %>% print() %>% grepl(c("cat", "cat dog", "dog cat"))
# find something that ends with word rx() %>% rx_find("cat") %>% rx_end_of_line() %>% print() %>% grepl(c("cat", "cat dog", "dog cat"))
# find something that starts with and ends with words rx() %>% rx_start_of_line() %>% rx_find("cat") %>% rx_anything() %>% rx_find("dog") %>% rx_end_of_line() %>% print() %>% grepl(c("cat", "cat dog", "dog cat"))
# find something regardless of case rx() %>% rx_find("cat") %>% rx_with_any_case() %>% print() %>% grepl(c("cat", "CAT"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.