9
The documentation for str_split in the stringr package states that for the pattern argument:
If "" splits into individual characters.
which suggests it behaves the same as strsplit in this regard. However,
library(stringr)
str_split("abcab","")
[[1]]
[1] "" "a" "b" "c" "a" "b"
with a leading empty string. This compares with,
strsplit("abcab","")
[[1]]
[1] "a" "b" "c" "a" "b"
Leading empty strings seems to be normal behavior when splitting on non-empty strings,
strsplit("abcab","ab")
[[1]]
[1] "" "c"
but even then, str_split generates an 'extra' trailing empty string:
str_split("abcab","ab")
[[1]]
[1] "" "c" ""
Is this discrepancy a bug, feature, an error in the documentation or just a different notion of what's 'expected behavior'?