File: grep_sub.Rd

package info (click to toggle)
r-cran-xfun 0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680 kB
  • sloc: ansic: 242; sh: 22; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 673 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
% 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}()} 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)
}