Skip to content

Commit 88a0560

Browse files
authored
Fix for reverse search, fixes #39401, fixes #40244(#41203)
1 parent e34c77b commit 88a0560

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

base/strings/search.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ function _rsearchindex(s::AbstractVector{<:Union{Int8,UInt8}}, t::AbstractVector
459459
n = length(t)
460460
m = length(s)
461461
k = Int(_k) - sentinel
462-
k < 1 && throw(BoundsError(s, _k))
462+
k < 0 && throw(BoundsError(s, _k))
463463

464464
if n == 0
465465
return 0 <= k <= m ? max(k, 1) : sentinel

test/strings/search.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ for str in [astr]
9797
@test findprev('l', str, 2) == nothing
9898
@test findlast(',', str) == 6
9999
@test findprev(',', str, 5) == nothing
100+
@test findlast(str, "") == nothing
101+
@test findlast(str^2, str) == nothing
100102
@test findlast('\n', str) == 14
101103
end
102104

test/strings/util.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ end
163163
@test split("", "") == rsplit("", "") == [""]
164164
@test split("abc", "") == rsplit("abc", "") == ["a","b","c"]
165165
@test rsplit("abc", "", limit=2) == ["ab","c"]
166+
@test rsplit("", "//") == [""]
166167
@test split("abc", "", limit=2) == ["a","bc"]
167168

168169
@test split("", r"") == [""]

0 commit comments

Comments
 (0)