Description Usage Arguments Details Value Examples
Generate a Regular Expression for Finding Two Patterns Occurring Near Each Other
1 | match_near(pattern1, pattern2, max_distance = 250)
|
pattern1, pattern2 |
Two character strings each containing a word or a stringi-search-regex to be found near each other. |
max_distance |
The maximum number of words intervening between the two specified patterns |
match_near
is a convenience function that creates a regular expression pattern for finding if two words (or other regular expression patterns) occur within a specified number of words of each other
A regular expression pattern
1 2 3 4 5 6 7 | colors <- "red|blue|yellow"
sentences <- c("The car parked by their house was red",
"The yellow cat enjoys the sun atop the car's roof",
"The blue city bus passed right by the stopped car")
stringr::str_detect(sentences, match_near(colors, "car", 5))
stringr::str_detect(sentences, match_near(colors, "car|bus", 5))
stringr::str_detect(sentences, match_near(colors, "car", 10))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.