strsplit_ctl {fansi} | R Documentation |
A drop-in replacement for base::strsplit. It will be noticeably slower, but should otherwise behave the same way except for CSI SGR sequence awareness.
strsplit_ctl(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE, warn = getOption("fansi.warn"), term.cap = getOption("fansi.term.cap"))
x |
a character vector, or, unlike base::strsplit an object that can be coerced to character. |
split |
character vector (or object which can be coerced to such)
containing regular expression(s) (unless |
fixed |
logical. If |
perl |
logical. Should Perl-compatible regexps be used? |
useBytes |
logical. If |
warn |
TRUE (default) or FALSE, whether to warn when potentially
problematic Control Sequences are encountered. These could cause the
assumptions |
term.cap |
character a vector of the capabilities of the terminal, can
be any combination "bright" (SGR codes 90-97, 100-107), "256" (SGR codes
starting with "38;5" or "48;5"), and "truecolor" (SGR codes starting with
"38;2" or "48;2"). Changing this parameter changes how |
list, see base::strsplit.
Non-ASCII strings are converted to and returned in UTF-8 encoding. The
split positions are computed after both x
and split
are converted to
UTF-8.
fansi for details on how Control Sequences are interpreted, particularly if you are getting unexpected results, base::strsplit for details on the splitting.
strsplit_ctl("\033[31mhello\033[42m world!", " ")