Sandwich Text Between Placeholders
sandwich_text.RdSandwiches strings between one or two placeholders.
Arguments
- x
A string or character vector.
- placeholder
One or two placeholders to sandwich each element of
xbetween. When two placeholders are provided,xwill be sandwiched between them with the first at the start and second at the end. Otherwise,xwill be sandwiched at both start and end by the same placeholder.- add_dup
Whether to add placeholders even if the same character is already found in that position, as a boolean (default:
TRUE).
See also
Other general utilities:
length_sort(),
max_paren_depth(),
suggest_regex()
Examples
sandwich_text("a", placeholder = "h")
#> [1] "hah"
sandwich_text("a", placeholder = c("b", "h"))
#> [1] "bah"
sandwich_text("bah", placeholder = c("b", "h"), add_dup = TRUE)
#> [1] "bbahh"
sandwich_text("bah", placeholder = c("b", "h"), add_dup = FALSE)
#> [1] "bah"
sandwich_text("bah", placeholder = "h", add_dup = FALSE)
#> [1] "hbah"