text <- cli:::lorem_ipsum()
# Highlight some words, that start with 's'
rexp <- gregexpr("\\b([sS][a-zA-Z]+)\\b", text)
regmatches(text, rexp) <- lapply(regmatches(text, rexp), col_red)
cat(text)
wrp <- ansi_strwrap(text, width = 40)
cat(wrp, sep = "\n")
Run the code above in your browser using DataLab