Fix indices/1 and rindex/1 in case of overlapping matches in strings
Fixes #2433
This commit is contained in:
1 parent
bf4390562f
commit
1915b689f7
2 files changed
+5
-1
No files matched your search
@@ -1296,7 +1296,7 @@ jv jv_string_indexes(jv j, jv k) {
|
|||||||
p = jstr;
|
p = jstr;
|
||||||
while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) {
|
while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) {
|
||||||
a = jv_array_append(a, jv_number(p - jstr));
|
a = jv_array_append(a, jv_number(p - jstr));
|
||||||
p += idxlen;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jv_free(j);
|
jv_free(j);
|
||||||
|
|||||||
@@ -1265,6 +1265,10 @@ split("")
|
|||||||
"a,bc,def,ghij,klmno"
|
"a,bc,def,ghij,klmno"
|
||||||
[1,13,[1,4,8,13]]
|
[1,13,[1,4,8,13]]
|
||||||
|
|
||||||
|
[ index("aba"), rindex("aba"), indices("aba") ]
|
||||||
|
"xababababax"
|
||||||
|
[1,7,[1,3,5,7]]
|
||||||
|
|
||||||
indices(1)
|
indices(1)
|
||||||
[0,1,1,2,3,4,1,5]
|
[0,1,1,2,3,4,1,5]
|
||||||
[1,2,6]
|
[1,2,6]
|
||||||
|
|||||||
Reference in new issue
Block a user