Closed jakob-r closed 5 years ago
Nah, this behavior is documented in the package manual:
[...]this is equivalent to something like ‘for (i in 1:npatterns) str <- stri_replace_all(str, pattern[i], replacement[i]’. [...]
Recently a similar issue was raised regarding stri_trans_char
and overlapping maps, see #343
so in your example, you'd have:
> stringi::stri_trans_char(c("A", "B", "A"), "AB", "BC")
[1] "B" "C" "B"
Reproducing a similar behavior in case of stri_replace_all
could be error-prone, I think, because the patterns might be of different lengths and the matches to patterns might overlap -- what then?
Consider the following example:
The output is:
Instead I would expect
Is this intended or a bug?