fuse_regex: Fuse regular expressions

fuse_regexR Documentation

Fuse regular expressions

Description

Combines a vector or list of regular expressions to a single one (by logical OR).

Usage

fuse_regex(..., .literal = FALSE)

Arguments

...

Regular expressions. All elements will be converted to type character before fusing. Dynamic dots are supported.

.literal

Whether or not the input should be interpreted literally instead of as regular expressions. If TRUE, all elements of ... are wrapped in the literal escape sequences ⁠\Q⁠ and ⁠\E⁠.

Value

A character scalar.

See Also

The rex package which provides an intuitive framework to build complex regular expressions.

Other string functions: as_chr(), as_comment_str(), as_line_feed_chr(), as_str(), capitalize_first(), dsv_colnames(), enum_str(), escape_lf(), prettify_nr(), sentenceify(), wrap_chr()

Examples

# perform some (nonsense) Jane Austen text extraction
regex <- c("My dear Jane",
           "make haste, ",
           "(?i)\\bevil")

readr::read_lines(file = "https://www.gutenberg.org/cache/epub/1342/pg1342.txt") |>
  stringr::str_subset(pattern = pal::fuse_regex(regex))

salim-b/pal documentation built on Feb. 28, 2025, 6:51 p.m.