replace_in_string: Replace (substitutes) patterns in a string.

Description Usage Arguments Details Value TODO Examples

View source: R/string.R

Description

Wrapper of the stringi stri_replace_ family of functions.

Usage

1
replace_in_string(string, from, to, squish_ws = FALSE)

Arguments

string

A character vector.

from

A string vector containing the patterns (regex, as string) to be matched.

to

A string vector of the replacements (element-wise) for from.

squish_ws

A boolean; determines if trailing white spaces and repeated whitespace inside a string (generated by the replacement), are trimmed or not.

Details

Given two vectors mapping the patterns to be replaced with their replacements, return a new string.

Value

A character vector.

TODO

This is a bare bone implementation; dispatch to stringi functions will be implemented.

Examples

1
2
3
4
string <- "Here, is a string: this is a test one."
from <- c("H.*,", ":", "\\.")
to <- c("", "", "")
replace_in_string(string, from, to)

xavier-gilbert/sabre documentation built on May 7, 2021, 12:40 p.m.