Skip to contents

Sandwiches strings between one or two placeholders.

Usage

sandwich_text(x, placeholder, ...)

Arguments

x

A string or character vector.

placeholder

One or two placeholders to sandwich each element of x between. When two placeholders are provided, x will be sandwiched between them with the first on the left and second on the right. Otherwise, x will be sandwiched on both sides by the same placeholder.

...

Arguments passed on to base::paste0

collapse

an optional character string to separate the results. Not NA_character_.

recycle0

logical indicating if zero-length character arguments should lead to the zero-length character(0) after the sep-phase (which turns into "" in the collapse-phase, i.e., when collapse is not NULL).

Examples

sandwich_text("a", placeholder = "h")
#> [1] "hah"
sandwich_text("a", placeholder = c("b", "h"))
#> [1] "bah"