unglue_sub: unglue_sub

Description Usage Arguments Examples

View source: R/unglue_sub.R

Description

substitute substrings using strings or replacement functions

Usage

1
unglue_sub(x, patterns, repl, open = "{", close = "}")

Arguments

x

character vector

patterns

a character vector or a list of character vectors, if a list, items will be pasted using an empty separator ("").

repl

function to apply on matched substrings, formula (if package rlang is installed), substring, or named list of such.

open

The opening delimiter.

close

The closing delimiter.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
unglue_sub(
  c("a and b", "foo or bar"),
  c("{x} and {y}", "{x} or {z}"),
  "XXX")

unglue_sub(
  c("a and b", "foo or bar"),
  c("{x} and {y}", "{x} or {z}"),
  toupper)

unglue_sub(
  c("a and b", "foo or BAR"),
  c("{x} and {y}", "{x} or {z}"),
  list(x= "XXX", y = toupper, z = tolower))

unglue documentation built on July 1, 2020, 5:46 p.m.