match_all: Generate a Regular Expression for Finding Multiple Patterns...

Description Usage Arguments Details Value Examples

View source: R/match_all.R

Description

Generate a Regular Expression for Finding Multiple Patterns in a Text

Usage

1
match_all(pattern1, pattern2 = "")

Arguments

pattern1, pattern2

Two character strings each containing a word or a stringi-search-regex to be found in the same text. Alternately, pattern1 can be a character vector.

max_distance

The maximum number of words intervening between the two specified patterns

Details

match_all is a convenience function that creates a regular expression pattern for finding if two words (or other regular expression patterns) occur within a text

Value

A regular expression pattern

Examples

1
2
3
4
5
6
7
8
colors <- "red|blue|yellow"
sentences <- c("The car parked by their house was red",
               "Her yellow cat enjoys the sun on the windowsill",
               "The blue city bus passed right by the stopped truck")
stringr::str_detect(sentences, match_all("yellow", "car"))
stringr::str_detect(sentences, match_all(colors, "car"))
stringr::str_detect(sentences, match_all(colors, "car|bus"))
stringr::str_detect(sentences, match_all(c("bus", "truck", "city")))

mariolaespinosa/historicalnetworks documentation built on Feb. 9, 2022, 12:31 p.m.