Skip to content

Commit b780a89

Browse files
committed
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', ''}`.
1 parent cdc6c62 commit b780a89

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/com/laytonsmith/core/functions/StringHandling.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommand
13281328
return array;
13291329
}
13301330
int splitsFound = 0;
1331-
for(int i = 0; i < string.length() - split.length() && splitsFound < limit; i++) {
1331+
for(int i = 0; i <= string.length() - split.length() && splitsFound < limit; i++) {
13321332
if(string.substring(i, i + split.length()).equals(split)) {
13331333
//Split point found
13341334
splitsFound++;

0 commit comments

Comments
 (0)