Sandwich Text Between Placeholders
sandwich_text.Rd
Sandwiches strings between one or two placeholders.
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-lengthcharacter(0)
after thesep
-phase (which turns into""
in thecollapse
-phase, i.e., whencollapse
is notNULL
).
Examples
sandwich_text("a", placeholder = "h")
#> [1] "hah"
sandwich_text("a", placeholder = c("b", "h"))
#> [1] "bah"