interleave: Interleave one string with another

View source: R/string_tools.R

interleaveR Documentation

Interleave one string with another

Description

Interleave a string with another string. By default, interleaves newlines (⁠\\n⁠) between each letter to help format a compact letter display.

Usage

interleave(str, insert = "\n", split = character(0))

Arguments

str

(Character) The string to be split into sections.

insert

(Character) The string to be inserted between sections.

split

(Character) Regular expression to split str by. If its length is zero (the default), it will split at every character.

Value

A Character vector.

Examples

interleave(c("hello", "hey"), "-")

## [1] "h-e-l-l-o" "h-e-y" 

interleave(c("hello", "hey"), insert = "|_|", split = "el")
## [1] "h|_|lo" "hey"  

interleave(c(1234, 9876), "-")

## [1] "1-2-3-4" "9-8-7-6"


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.