Skip to content

Commit 992b562

Browse files
sostockKristofferC
authored andcommitted
Fix replace (#36953) (#36959)
(cherry picked from commit 00f2133)
1 parent 511a53f commit 992b562

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

base/strings/util.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ function replace(str::String, pat_repl::Pair; count::Integer=typemax(Int))
521521
i = k = nextind(str, k)
522522
end
523523
r = something(findnext(pattern,str,k), 0)
524-
r == 0:-1 || n == count && break
524+
r === 0:-1 || n == count && break
525525
j, k = first(r), last(r)
526526
n += 1
527527
end

test/strings/util.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ end
297297
@test replace("a", in("a") => typeof) == "Char"
298298
@test replace("a", ['a'] => typeof) == "Char"
299299

300+
# Issue 36953
301+
@test replace("abc", "" => "_", count=1) == "_abc"
302+
300303
end
301304

302305
@testset "chomp/chop" begin

0 commit comments

Comments
 (0)