Skip to content

Commit

Permalink
Fix replace (#36953) (#36959)
Browse files Browse the repository at this point in the history
(cherry picked from commit 00f2133)
  • Loading branch information
sostock authored and KristofferC committed Aug 10, 2020
1 parent f3d8ffb commit dc767cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ function replace(str::String, pat_repl::Pair; count::Integer=typemax(Int))
i = k = nextind(str, k)
end
r = something(findnext(pattern,str,k), 0)
r == 0:-1 || n == count && break
r === 0:-1 || n == count && break
j, k = first(r), last(r)
n += 1
end
Expand Down
3 changes: 3 additions & 0 deletions test/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ end
@test replace("a", in("a") => typeof) == "Char"
@test replace("a", ['a'] => typeof) == "Char"

# Issue 36953
@test replace("abc", "" => "_", count=1) == "_abc"

end

@testset "chomp/chop" begin
Expand Down

0 comments on commit dc767cf

Please sign in to comment.