bound_rx: Transform character strings into one regular expression

View source: R/misc.R

bound_rxR Documentation

Transform character strings into one regular expression

Description

Passing a list of patterns to a 'stringr' function that do not match the length of the 'text' argument yields unexpected results. Converting the expression with a 'map' function is cumbersome and sometimes slow. This transformation solves that problem and may provide an increase in speed Using 'fixed()' and a 'map'function may be faster but will match different things.

Usage

bound_rx(rx_var, leftbound = "\\b", rightbound = "\\b", by_element = FALSE)

Arguments

rx_var

A charater vector

by_element

Value

An atomic character vector with a valid regex

Examples


Find all individual letters in a text regardless of case.

sample_text <- c("ag;als", "w a;lsg;lak B", "l A jlajksf k")

str_count(sample_text, bound_rx(letters))

AltfunsMA/cptools documentation built on Aug. 7, 2022, 5:44 p.m.