Debian Codegraph @

man/grep_sub.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/io.R
3 \name{grep_sub}
4 \alias{grep_sub}
5 \title{Perform replacement with \code{gsub()} on elements matched from \code{grep()}}
6 \usage{
7 grep_sub(pattern, replacement, x, ...)
8 }
9 \arguments{
10 \item{pattern, replacement, x, ...}{Passed to \code{\link[=grep]{grep()}} and
11 \code{gsub()}.}
12 }
13 \value{
14 A character vector.
15 }
16 \description{
17 This function is a shorthand of \code{gsub(pattern, replacement, grep(pattern, x, value = TRUE))}.
18 }
19 \examples{
20 # find elements that matches 'a[b]+c' and capitalize 'b' with perl regex
21 xfun::grep_sub("a([b]+)c", "a\\\\U\\\\1c", c("abc", "abbbc", "addc", "123"), perl = TRUE)
22 }