Splits character vectors into substrings. This is a convenience wrapper
around stringi::stri_split_fixed() and
stringi::stri_split_regex() with simplified defaults.
Details
If the input x has length 1, the result is returned as a character
vector instead of a list for convenience.
This function provides a simplified interface to string splitting using
the stringi package. It avoids some of the complexity of
base::strsplit() while providing consistent and Unicode-aware
behavior.
See also
stringi::stri_split_fixed(),
stringi::stri_split_regex(), base::strsplit()
string-overview for an overview of all string utilities in pharos.
Examples
strSplit("a,b,c", ",", fixed = TRUE)
#> [1] "a" "b" "c"
strSplit(c("a b", "c d"), " ")
#> [[1]]
#> [1] "a" "b"
#>
#> [[2]]
#> [1] "c" "d"
#>
# regex splitting
strSplit("a1b2c3", "\\d")
#> [1] "a" "b" "c" ""
