Skip to content

Commit bb332b1

Browse files
committed
deprecate replace(s::String, pat, r, n) to replace(s, pat=>r, count=n)
1 parent 4ff02f0 commit bb332b1

File tree

26 files changed

+151
-149
lines changed

26 files changed

+151
-149
lines changed

base/deprecated.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,14 +1344,19 @@ end
13441344
function replace(s::AbstractString, pat, f, n::Integer)
13451345
if n <= 0
13461346
depwarn(string("`replace(s, pat, r, count)` with `count <= 0` is deprecated, use ",
1347-
"`replace(s, pat, r, typemax(Int))` or `replace(s, pat, r)` instead"),
1347+
"`replace(s, pat=>r, count=typemax(Int))` or `replace(s, pat=>r)` instead"),
13481348
:replace)
1349-
replace(s, pat, f)
1349+
replace(s, pat=>f)
13501350
else
1351-
replace_new(String(s), pat, f, n)
1351+
depwarn(string("`replace(s, pat, r, count)` is deprecated, use ",
1352+
"`replace(s, pat=>r, count=count)`"),
1353+
:replace)
1354+
replace(String(s), pat=>f, count=n)
13521355
end
13531356
end
13541357

1358+
@deprecate replace(s::AbstractString, pat, f) replace(s, pat=>f)
1359+
13551360
# PR #22475
13561361
@deprecate ntuple(f, ::Type{Val{N}}) where {N} ntuple(f, Val(N))
13571362
@deprecate fill_to_length(t, val, ::Type{Val{N}}) where {N} fill_to_length(t, val, Val(N)) false

base/libgit2/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Standardise the path string `path` to use POSIX separators.
8383
"""
8484
function posixpath end
8585
if Sys.iswindows()
86-
posixpath(path) = replace(path,'\\','/')
86+
posixpath(path) = replace(path,'\\' => '/')
8787
elseif Sys.isunix()
8888
posixpath(path) = path
8989
end

base/markdown/GitHub/table.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function parserow(stream::IO)
1111
row = split(line, r"(?<!\\)\|")
1212
length(row) == 1 && return
1313
isempty(row[1]) && shift!(row)
14-
map!(x -> strip(replace(x, "\\|", "|")), row, row)
14+
map!(x -> strip(replace(x, "\\|" => "|")), row, row)
1515
isempty(row[end]) && pop!(row)
1616
return row
1717
end
@@ -104,7 +104,7 @@ _dash(width, align) =
104104

105105
function plain(io::IO, md::Table)
106106
cells = mapmap(md.rows) do each
107-
replace(plaininline(each), "|", "\\|")
107+
replace(plaininline(each), "|" => "\\|")
108108
end
109109
padcells!(cells, md.align, len = length, min = 3)
110110
for i = axes(cells,1)

base/markdown/render/html.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ for ch in "'`!\$%()=+{}[]"
3131
end
3232

3333
function htmlesc(io::IO, s::AbstractString)
34-
# s1 = replace(s, r"&(?!(\w+|\#\d+);)", "&amp;")
34+
# s1 = replace(s, r"&(?!(\w+|\#\d+);)" => "&amp;")
3535
for ch in s
3636
print(io, get(_htmlescape_chars, ch, ch))
3737
end

base/markdown/render/rst.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ end
124124

125125
rstinline(io::IO, f::Footnote) = print(io, "[", f.id, "]_")
126126

127-
rstescape(s) = replace(s, "\\", "\\\\")
127+
rstescape(s) = replace(s, "\\" => "\\\\")
128128

129129
rstinline(io::IO, s::AbstractString) = print(io, rstescape(s))
130130

base/markdown/render/terminal/formatting.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151
# Wrapping
5252

5353
function ansi_length(s)
54-
replace(s, r"\e\[[0-9]+m", "") |> length
54+
replace(s, r"\e\[[0-9]+m" => "") |> length
5555
end
5656

5757
words(s) = split(s, " ")

base/markdown/render/terminal/render.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function terminline(io::IO, content::Vector)
114114
end
115115

116116
function terminline(io::IO, md::AbstractString)
117-
print(io, replace(md, r"[\s\t\n]+", " "))
117+
print(io, replace(md, r"[\s\t\n]+" => " "))
118118
end
119119

120120
function terminline(io::IO, md::Bold)

base/methodshow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function url(m::Method)
203203
file = string(m.file)
204204
line = m.line
205205
line <= 0 || ismatch(r"In\[[0-9]+\]", file) && return ""
206-
Sys.iswindows() && (file = replace(file, '\\', '/'))
206+
Sys.iswindows() && (file = replace(file, '\\' => '/'))
207207
if inbase(M)
208208
if isempty(Base.GIT_VERSION_INFO.commit)
209209
# this url will only work if we're on a tagged release

base/pkg/reqs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Requirement <: Line
1919
system::Vector{AbstractString}
2020

2121
function Requirement(content::AbstractString)
22-
fields = split(replace(content, r"#.*$", ""))
22+
fields = split(replace(content, r"#.*$" => ""))
2323
system = AbstractString[]
2424
while !isempty(fields) && fields[1][1] == '@'
2525
push!(system,shift!(fields)[2:end])

base/process.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function show(io::IO, cmd::Cmd)
107107
with_output_color(:underline, io) do io
108108
print_shell_word(io, arg, shell_special)
109109
end
110-
end, '`', "\\`")
110+
end, '`' => "\\`")
111111
end, ' '))
112112
print(io, '`')
113113
print_env && (print(io, ","); show(io, cmd.env))

0 commit comments

Comments
 (0)