unglue_sub: unglue_sub

View source: R/unglue_sub.R

unglue_subR Documentation

unglue_sub

Description

substitute substrings using strings or replacement functions

Usage

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

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))


moodymudskipper/unglue documentation built on Dec. 8, 2024, 9:07 p.m.