% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/io.R
\name{grep_sub}
\alias{grep_sub}
\title{Perform replacement with \code{gsub()} on elements matched from \code{grep()}}
\usage{
grep_sub(pattern, replacement, x, ...)
}
\arguments{
\item{pattern, replacement, x, ...}{Passed to \code{\link[=grep]{grep()}} and
\code{gsub()}.}
}
\value{
A character vector.
}
\description{
This function is a shorthand of \code{gsub(pattern, replacement, grep(pattern, x, value = TRUE))}.
}
\examples{
# find elements that matches 'a[b]+c' and capitalize 'b' with perl regex
xfun::grep_sub("a([b]+)c", "a\\\\U\\\\1c", c("abc", "abbbc", "addc", "123"), perl = TRUE)
}
