Skip to content
Permalink
Browse files
Fix split() for strings ending with the split
Allow `split()` (and non-regex `reg_split()`) to match the split on the last possible part of the string as well.
Fixes `split('b', 'ab')` resulting in `{'ab'}`, rather than `{'a', ''}`.
  • Loading branch information
Pieter12345 committed Aug 17, 2020
1 parent cdc6c62 commit b780a89bf991201192a9093e72ec444569a6fd9a
Showing 1 changed file with 1 addition and 1 deletion.
@@ -1328,7 +1328,7 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommand
return array;
}
int splitsFound = 0;
for(int i = 0; i < string.length() - split.length() && splitsFound < limit; i++) {
for(int i = 0; i <= string.length() - split.length() && splitsFound < limit; i++) {
if(string.substring(i, i + split.length()).equals(split)) {
//Split point found
splitsFound++;

0 comments on commit b780a89

Please sign in to comment.