Skip to content

Commit d6fde5a

Browse files
committed
Change find* methods to return nothing instead of than empty ranges for no match
This is more consistent with functions which return a single index. It also allows distinguishing no match from an empty match.
1 parent abf8be3 commit d6fde5a

File tree

10 files changed

+93
-85
lines changed

10 files changed

+93
-85
lines changed

NEWS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ This section lists changes that do not have deprecation warnings.
404404
and higher-dimensional arrays insted of linear indices as was previously the case.
405405
Use `LinearIndices(a)[findall(f, a)]` and similar constructs to compute linear indices.
406406

407-
* The `find*` functions which return scalars, i.e. `findnext`, `findprev`, `findfirst`,
407+
* The `find*` functions, i.e. `findnext`, `findprev`, `findfirst`,
408408
and `findlast`, as well as `indexin`, now return `nothing` when no match is found rather
409-
than 0 ([#25472], [#25662]).
409+
than `0` or `0:-1` ([#25472], [#25662], [#26149])
410410

411411
* The `Base.HasShape` iterator trait has gained a type parameter `N` indicating the
412412
number of dimensions, which must correspond to the length of the tuple returned by
@@ -1359,3 +1359,4 @@ Command-line option changes
13591359
[#25990]: https://github.com/JuliaLang/julia/issues/25990
13601360
[#25998]: https://github.com/JuliaLang/julia/issues/25998
13611361
[#26009]: https://github.com/JuliaLang/julia/issues/26009
1362+
[#26149]: https://github.com/JuliaLang/julia/issues/26149

base/deprecated.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,9 +1193,9 @@ end
11931193
@deprecate_binding HasOrder Ordered
11941194
@deprecate_binding ArithmeticOverflows ArithmeticWraps
11951195

1196-
@deprecate search(str::Union{String,SubString}, re::Regex, idx::Integer) findnext(re, str, idx)
1197-
@deprecate search(s::AbstractString, r::Regex, idx::Integer) findnext(r, s, idx)
1198-
@deprecate search(s::AbstractString, r::Regex) findfirst(r, s)
1196+
@deprecate search(str::Union{String,SubString}, re::Regex, idx::Integer) coalesce(findnext(re, str, idx), 0:-1)
1197+
@deprecate search(s::AbstractString, r::Regex, idx::Integer) coalesce(findnext(r, s, idx), 0:-1)
1198+
@deprecate search(s::AbstractString, r::Regex) coalesce(findfirst(r, s), 0:-1)
11991199
@deprecate search(s::AbstractString, c::Char, i::Integer) coalesce(findnext(equalto(c), s, i), 0)
12001200
@deprecate search(s::AbstractString, c::Char) coalesce(findfirst(equalto(c), s), 0)
12011201
@deprecate search(a::ByteArray, b::Union{Int8,UInt8}, i::Integer) coalesce(findnext(equalto(b), a, i), 0)
@@ -1207,31 +1207,31 @@ end
12071207

12081208
@deprecate search(s::AbstractString, c::Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}, i::Integer) coalesce(findnext(occursin(c), s, i), 0)
12091209
@deprecate search(s::AbstractString, c::Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}) coalesce(findfirst(occursin(c), s), 0)
1210-
@deprecate search(s::AbstractString, t::AbstractString, i::Integer) findnext(t, s, i)
1211-
@deprecate search(s::AbstractString, t::AbstractString) findfirst(t, s)
1210+
@deprecate search(s::AbstractString, t::AbstractString, i::Integer) coalesce(findnext(t, s, i), 0:-1)
1211+
@deprecate search(s::AbstractString, t::AbstractString) coalesce(findfirst(t, s), 0:-1)
12121212

12131213
@deprecate search(buf::IOBuffer, delim::UInt8) coalesce(findfirst(equalto(delim), buf), 0)
12141214
@deprecate search(buf::Base.GenericIOBuffer, delim::UInt8) coalesce(findfirst(equalto(delim), buf), 0)
12151215

12161216
@deprecate rsearch(s::AbstractString, c::Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}, i::Integer) coalesce(findprev(occursin(c), s, i), 0)
12171217
@deprecate rsearch(s::AbstractString, c::Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}) coalesce(findlast(occursin(c), s), 0)
1218-
@deprecate rsearch(s::AbstractString, t::AbstractString, i::Integer) findprev(t, s, i)
1219-
@deprecate rsearch(s::AbstractString, t::AbstractString) findlast(t, s)
1218+
@deprecate rsearch(s::AbstractString, t::AbstractString, i::Integer) coalesce(findprev(t, s, i), 0:-1)
1219+
@deprecate rsearch(s::AbstractString, t::AbstractString) coalesce(findlast(t, s), 0:-1)
12201220

1221-
@deprecate rsearch(str::Union{String,SubString}, re::Regex, idx::Integer) findprev(re, str, idx)
1222-
@deprecate rsearch(str::Union{String,SubString}, re::Regex) findlast(re, str)
1223-
@deprecate rsearch(s::AbstractString, r::Regex, idx::Integer) findprev(r, s, idx)
1224-
@deprecate rsearch(s::AbstractString, r::Regex) findlast(r, s)
1221+
@deprecate rsearch(str::Union{String,SubString}, re::Regex, idx::Integer) coalesce(findprev(re, str, idx), 0:-1)
1222+
@deprecate rsearch(str::Union{String,SubString}, re::Regex) coalesce(findlast(re, str), 0:-1)
1223+
@deprecate rsearch(s::AbstractString, r::Regex, idx::Integer) coalesce(findprev(r, s, idx), 0:-1)
1224+
@deprecate rsearch(s::AbstractString, r::Regex) coalesce(findlast(r, s), 0:-1)
12251225
@deprecate rsearch(s::AbstractString, c::Char, i::Integer) coalesce(findprev(equalto(c), s, i), 0)
12261226
@deprecate rsearch(s::AbstractString, c::Char) coalesce(findlast(equalto(c), s), 0)
12271227
@deprecate rsearch(a::Union{String,ByteArray}, b::Union{Int8,UInt8}, i::Integer = lastindex(a)) coalesce(findprev(equalto(b), a, i), 0)
12281228
@deprecate rsearch(a::String, b::Union{Int8,UInt8}, i::Integer = lastindex(a)) coalesce(findprev(equalto(Char(b)), a, i), 0)
12291229
@deprecate rsearch(a::ByteArray, b::Char, i::Integer = lastindex(a)) coalesce(findprev(equalto(UInt8(b)), a, i), 0)
12301230

1231-
@deprecate searchindex(s::AbstractString, t::AbstractString) first(findfirst(t, s))
1232-
@deprecate searchindex(s::AbstractString, t::AbstractString, i::Integer) first(findnext(t, s, i))
1233-
@deprecate rsearchindex(s::AbstractString, t::AbstractString) first(findlast(t, s))
1234-
@deprecate rsearchindex(s::AbstractString, t::AbstractString, i::Integer) first(findprev(t, s, i))
1231+
@deprecate searchindex(s::AbstractString, t::AbstractString) first(coalesce(findfirst(t, s), 0:-1))
1232+
@deprecate searchindex(s::AbstractString, t::AbstractString, i::Integer) first(coalesce(findnext(t, s, i), 0:-1))
1233+
@deprecate rsearchindex(s::AbstractString, t::AbstractString) first(coalesce(findlast(t, s), 0:-1))
1234+
@deprecate rsearchindex(s::AbstractString, t::AbstractString, i::Integer) first(coalesce(findprev(t, s, i), 0:-1))
12351235

12361236
@deprecate searchindex(s::AbstractString, c::Char) coalesce(findfirst(equalto(c), s), 0)
12371237
@deprecate searchindex(s::AbstractString, c::Char, i::Integer) coalesce(findnext(equalto(c), s, i), 0)

base/regex.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,11 @@ function findnext(re::Regex, str::Union{String,SubString}, idx::Integer)
272272
end
273273
opts = re.match_options
274274
compile(re)
275-
PCRE.exec(re.regex, str, idx-1, opts, re.match_data) ?
276-
((Int(re.ovec[1])+1):prevind(str,Int(re.ovec[2])+1)) : (0:-1)
275+
if PCRE.exec(re.regex, str, idx-1, opts, re.match_data)
276+
(Int(re.ovec[1])+1):prevind(str,Int(re.ovec[2])+1)
277+
else
278+
nothing
279+
end
277280
end
278281
findnext(r::Regex, s::AbstractString, idx::Integer) = throw(ArgumentError(
279282
"regex search is only available for the String type; use String(s) to convert"

base/strings/search.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,10 @@ function _search(s::Union{AbstractString,ByteArray},
217217
idx = _searchindex(s,t,i)
218218
if isempty(t)
219219
idx:idx-1
220+
elseif idx > 0
221+
idx:(idx + lastindex(t) - 1)
220222
else
221-
idx:(idx > 0 ? idx + lastindex(t) - 1 : -1)
223+
nothing
222224
end
223225
end
224226

@@ -230,16 +232,16 @@ Find the next occurrence of `pattern` in `string` starting at position `start`.
230232
`pattern` can be either a string, or a regular expression, in which case `string`
231233
must be of type `String`.
232234
233-
The return value is a range of indexes where the matching sequence is found, such that
235+
The return value is a range of indices where the matching sequence is found, such that
234236
`s[findnext(x, s, i)] == x`:
235237
236238
`findnext("substring", string, i)` = `start:end` such that
237-
`string[start:end] == "substring"`, or `0:-1` if unmatched.
239+
`string[start:end] == "substring"`, or `nothing` if unmatched.
238240
239241
# Examples
240242
```jldoctest
241-
julia> findnext("z", "Hello to the world", 1)
242-
0:-1
243+
julia> findnext("z", "Hello to the world", 1) === nothing
244+
true
243245
244246
julia> findnext("o", "Hello to the world", 6)
245247
8:8
@@ -392,8 +394,10 @@ function _rsearch(s::Union{AbstractString,ByteArray},
392394
idx = _rsearchindex(s,t,i)
393395
if isempty(t)
394396
idx:idx-1
397+
elseif idx > 0
398+
idx:(idx + lastindex(t) - 1)
395399
else
396-
idx:(idx > 0 ? idx + lastindex(t) - 1 : -1)
400+
nothing
397401
end
398402
end
399403

@@ -405,16 +409,16 @@ Find the previous occurrence of `pattern` in `string` starting at position `star
405409
`pattern` can be either a string, or a regular expression, in which case `string`
406410
must be of type `String`.
407411
408-
The return value is a range of indexes where the matching sequence is found, such that
412+
The return value is a range of indices where the matching sequence is found, such that
409413
`s[findprev(x, s, i)] == x`:
410414
411415
`findprev("substring", string, i)` = `start:end` such that
412-
`string[start:end] == "substring"`, or `0:-1` if unmatched.
416+
`string[start:end] == "substring"`, or `nothing` if unmatched.
413417
414418
# Examples
415419
```jldoctest
416-
julia> findprev("z", "Hello to the world", 18)
417-
0:-1
420+
julia> findprev("z", "Hello to the world", 18) === nothing
421+
true
418422
419423
julia> findprev("o", "Hello to the world", 18)
420424
15:15

stdlib/REPL/src/REPL.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ function history_search(hist::REPLHistoryProvider, query_buffer::IOBuffer, respo
631631
# First the current response buffer
632632
if 1 <= searchstart <= lastindex(response_str)
633633
match = searchfunc2(searchdata, response_str, searchstart)
634-
if match != 0:-1
634+
if match !== nothing
635635
seek(response_buffer, first(match) - 1)
636636
return true
637637
end
@@ -642,7 +642,7 @@ function history_search(hist::REPLHistoryProvider, query_buffer::IOBuffer, respo
642642
for idx in idxs
643643
h = hist.history[idx]
644644
match = searchfunc1(searchdata, h)
645-
if match != 0:-1 && h != response_str && haskey(hist.mode_mapping, hist.modes[idx])
645+
if match !== nothing && h != response_str && haskey(hist.mode_mapping, hist.modes[idx])
646646
truncate(response_buffer, 0)
647647
write(response_buffer, h)
648648
seek(response_buffer, first(match) - 1)

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function afterusing(string::String, startpos::Int)
417417
isempty(str) && return false
418418
rstr = reverse(str)
419419
r = findfirst(r"\s(gnisu|tropmi)\b", rstr)
420-
isempty(r) && return false
420+
r === nothing && return false
421421
fr = reverseind(str, last(r))
422422
return contains(str[fr:end], r"^\b(using|import)\s*((\w+[.])*\w+\s*,\s*)*$")
423423
end

stdlib/REPL/src/docview.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ doc_completions(name::Symbol) = doc_completions(string(name))
493493
# Searching and apropos
494494

495495
# Docsearch simply returns true or false if an object contains the given needle
496-
docsearch(haystack::AbstractString, needle) = !isempty(findfirst(needle, haystack))
496+
docsearch(haystack::AbstractString, needle) = findfirst(needle, haystack) !== nothing
497497
docsearch(haystack::Symbol, needle) = docsearch(string(haystack), needle)
498498
docsearch(::Nothing, needle) = false
499499
function docsearch(haystack::Array, needle)

stdlib/REPL/test/repl.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ fake_repl() do stdin_write, stdout_read, repl
213213
# Issue #10222
214214
# Test ignoring insert key in standard and prefix search modes
215215
write(stdin_write, "\e[2h\e[2h\n") # insert (VT100-style)
216-
@test findfirst("[2h", readline(stdout_read)) == 0:-1
216+
@test findfirst("[2h", readline(stdout_read)) === nothing
217217
readline(stdout_read)
218218
write(stdin_write, "\e[2~\e[2~\n") # insert (VT220-style)
219-
@test findfirst("[2~", readline(stdout_read)) == 0:-1
219+
@test findfirst("[2~", readline(stdout_read)) === nothing
220220
readline(stdout_read)
221221
write(stdin_write, "1+1\n") # populate history with a trivial input
222222
readline(stdout_read)

test/strings/search.jl

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -115,83 +115,83 @@ for str in [u8str]
115115
end
116116

117117
# string forward search with a single-char string
118-
@test findfirst("x", astr) == 0:-1
118+
@test findfirst("x", astr) == nothing
119119
@test findfirst("H", astr) == 1:1
120-
@test findnext("H", astr, 2) == 0:-1
120+
@test findnext("H", astr, 2) == nothing
121121
@test findfirst("l", astr) == 3:3
122122
@test findnext("l", astr, 4) == 4:4
123123
@test findnext("l", astr, 5) == 11:11
124-
@test findnext("l", astr, 12) == 0:-1
124+
@test findnext("l", astr, 12) == nothing
125125
@test findfirst("\n", astr) == 14:14
126-
@test findnext("\n", astr, 15) == 0:-1
126+
@test findnext("\n", astr, 15) == nothing
127127

128-
@test findfirst("z", u8str) == 0:-1
129-
@test findfirst("", u8str) == 0:-1
128+
@test findfirst("z", u8str) == nothing
129+
@test findfirst("", u8str) == nothing
130130
@test findfirst("", u8str) == 1:1
131-
@test findnext("", u8str, 4) == 0:-1
131+
@test findnext("", u8str, 4) == nothing
132132
@test findfirst("", u8str) == 13:13
133-
@test findnext("", u8str, 16) == 0:-1
133+
@test findnext("", u8str, 16) == nothing
134134
@test findfirst("x", u8str) == 26:26
135135
@test findnext("x", u8str, 27) == 43:43
136-
@test findnext("x", u8str, 44) == 0:-1
136+
@test findnext("x", u8str, 44) == nothing
137137
@test findfirst("ε", u8str) == 5:5
138138
@test findnext("ε", u8str, 7) == 54:54
139-
@test findnext("ε", u8str, 56) == 0:-1
139+
@test findnext("ε", u8str, 56) == nothing
140140

141141
# strifindprev backward search with a single-char string
142-
@test findlast("x", astr) == 0:-1
142+
@test findlast("x", astr) == nothing
143143
@test findlast("H", astr) == 1:1
144144
@test findprev("H", astr, 2) == 1:1
145-
@test findprev("H", astr, 0) == 0:-1
145+
@test findprev("H", astr, 0) == nothing
146146
@test findlast("l", astr) == 11:11
147147
@test findprev("l", astr, 10) == 4:4
148148
@test findprev("l", astr, 4) == 4:4
149149
@test findprev("l", astr, 3) == 3:3
150-
@test findprev("l", astr, 2) == 0:-1
150+
@test findprev("l", astr, 2) == nothing
151151
@test findlast("\n", astr) == 14:14
152-
@test findprev("\n", astr, 13) == 0:-1
152+
@test findprev("\n", astr, 13) == nothing
153153

154-
@test findlast("z", u8str) == 0:-1
155-
@test findlast("", u8str) == 0:-1
154+
@test findlast("z", u8str) == nothing
155+
@test findlast("", u8str) == nothing
156156
@test findlast("", u8str) == 1:1
157-
@test findprev("", u8str, 0) == 0:-1
157+
@test findprev("", u8str, 0) == nothing
158158
#TODO: setting the limit in the middle of a wide char
159159
# makes findnext fail but findprev succeed.
160160
# Should findprev fail as well?
161-
#@test findprev("∀", u8str, 2) == 0:-1 # gives 1:3
161+
#@test findprev("∀", u8str, 2) == nothing # gives 1:3
162162
@test findlast("", u8str) == 13:13
163-
@test findprev("", u8str, 12) == 0:-1
163+
@test findprev("", u8str, 12) == nothing
164164
@test findlast("x", u8str) == 43:43
165165
@test findprev("x", u8str, 42) == 26:26
166-
@test findprev("x", u8str, 25) == 0:-1
166+
@test findprev("x", u8str, 25) == nothing
167167
@test findlast("ε", u8str) == 54:54
168168
@test findprev("ε", u8str, 53) == 5:5
169-
@test findprev("ε", u8str, 4) == 0:-1
169+
@test findprev("ε", u8str, 4) == nothing
170170

171171
# string forward search with a single-char regex
172-
@test findfirst(r"x", astr) == 0:-1
172+
@test findfirst(r"x", astr) == nothing
173173
@test findfirst(r"H", astr) == 1:1
174-
@test findnext(r"H", astr, 2) == 0:-1
174+
@test findnext(r"H", astr, 2) == nothing
175175
@test findfirst(r"l", astr) == 3:3
176176
@test findnext(r"l", astr, 4) == 4:4
177177
@test findnext(r"l", astr, 5) == 11:11
178-
@test findnext(r"l", astr, 12) == 0:-1
178+
@test findnext(r"l", astr, 12) == nothing
179179
@test findfirst(r"\n", astr) == 14:14
180-
@test findnext(r"\n", astr, 15) == 0:-1
181-
@test findfirst(r"z", u8str) == 0:-1
182-
@test findfirst(r"", u8str) == 0:-1
180+
@test findnext(r"\n", astr, 15) == nothing
181+
@test findfirst(r"z", u8str) == nothing
182+
@test findfirst(r"", u8str) == nothing
183183
@test findfirst(r"", u8str) == 1:1
184-
@test findnext(r"", u8str, 4) == 0:-1
184+
@test findnext(r"", u8str, 4) == nothing
185185
@test findfirst(r"", u8str) == findfirst(r"\u2200", u8str)
186186
@test findnext(r"", u8str, 4) == findnext(r"\u2200", u8str, 4)
187187
@test findfirst(r"", u8str) == 13:13
188-
@test findnext(r"", u8str, 16) == 0:-1
188+
@test findnext(r"", u8str, 16) == nothing
189189
@test findfirst(r"x", u8str) == 26:26
190190
@test findnext(r"x", u8str, 27) == 43:43
191-
@test findnext(r"x", u8str, 44) == 0:-1
191+
@test findnext(r"x", u8str, 44) == nothing
192192
@test findfirst(r"ε", u8str) == 5:5
193193
@test findnext(r"ε", u8str, 7) == 54:54
194-
@test findnext(r"ε", u8str, 56) == 0:-1
194+
@test findnext(r"ε", u8str, 56) == nothing
195195
for i = 1:lastindex(astr)
196196
@test findnext(r"."s, astr, i) == i:i
197197
end
@@ -231,18 +231,18 @@ for i = 1:lastindex(u8str)
231231
end
232232

233233
# string forward search with a two-char string literal
234-
@test findfirst("xx", "foo,bar,baz") == 0:-1
234+
@test findfirst("xx", "foo,bar,baz") == nothing
235235
@test findfirst("fo", "foo,bar,baz") == 1:2
236-
@test findnext("fo", "foo,bar,baz", 3) == 0:-1
236+
@test findnext("fo", "foo,bar,baz", 3) == nothing
237237
@test findfirst("oo", "foo,bar,baz") == 2:3
238-
@test findnext("oo", "foo,bar,baz", 4) == 0:-1
238+
@test findnext("oo", "foo,bar,baz", 4) == nothing
239239
@test findfirst("o,", "foo,bar,baz") == 3:4
240-
@test findnext("o,", "foo,bar,baz", 5) == 0:-1
240+
@test findnext("o,", "foo,bar,baz", 5) == nothing
241241
@test findfirst(",b", "foo,bar,baz") == 4:5
242242
@test findnext(",b", "foo,bar,baz", 6) == 8:9
243-
@test findnext(",b", "foo,bar,baz", 10) == 0:-1
243+
@test findnext(",b", "foo,bar,baz", 10) == nothing
244244
@test findfirst("az", "foo,bar,baz") == 10:11
245-
@test findnext("az", "foo,bar,baz", 12) == 0:-1
245+
@test findnext("az", "foo,bar,baz", 12) == nothing
246246

247247
# issue #9365
248248
# string forward search with a two-char UTF-8 (2 byte) string literal
@@ -286,32 +286,32 @@ end
286286
@test findprev("\U1f596\U1f596", "\U1f596\U1f596", lastindex("\U1f596\U1f596\U1f596")) == 1:5
287287

288288
# string backward search with a two-char string literal
289-
@test findlast("xx", "foo,bar,baz") == 0:-1
289+
@test findlast("xx", "foo,bar,baz") == nothing
290290
@test findlast("fo", "foo,bar,baz") == 1:2
291-
@test findprev("fo", "foo,bar,baz", 1) == 0:-1
291+
@test findprev("fo", "foo,bar,baz", 1) == nothing
292292
@test findlast("oo", "foo,bar,baz") == 2:3
293-
@test findprev("oo", "foo,bar,baz", 2) == 0:-1
293+
@test findprev("oo", "foo,bar,baz", 2) == nothing
294294
@test findlast("o,", "foo,bar,baz") == 3:4
295-
@test findprev("o,", "foo,bar,baz", 1) == 0:-1
295+
@test findprev("o,", "foo,bar,baz", 1) == nothing
296296
@test findlast(",b", "foo,bar,baz") == 8:9
297297
@test findprev(",b", "foo,bar,baz", 6) == 4:5
298-
@test findprev(",b", "foo,bar,baz", 3) == 0:-1
298+
@test findprev(",b", "foo,bar,baz", 3) == nothing
299299
@test findlast("az", "foo,bar,baz") == 10:11
300-
@test findprev("az", "foo,bar,baz", 10) == 0:-1
300+
@test findprev("az", "foo,bar,baz", 10) == nothing
301301

302302
# string search with a two-char regex
303-
@test findfirst(r"xx", "foo,bar,baz") == 0:-1
303+
@test findfirst(r"xx", "foo,bar,baz") == nothing
304304
@test findfirst(r"fo", "foo,bar,baz") == 1:2
305-
@test findnext(r"fo", "foo,bar,baz", 3) == 0:-1
305+
@test findnext(r"fo", "foo,bar,baz", 3) == nothing
306306
@test findfirst(r"oo", "foo,bar,baz") == 2:3
307-
@test findnext(r"oo", "foo,bar,baz", 4) == 0:-1
307+
@test findnext(r"oo", "foo,bar,baz", 4) == nothing
308308
@test findfirst(r"o,", "foo,bar,baz") == 3:4
309-
@test findnext(r"o,", "foo,bar,baz", 5) == 0:-1
309+
@test findnext(r"o,", "foo,bar,baz", 5) == nothing
310310
@test findfirst(r",b", "foo,bar,baz") == 4:5
311311
@test findnext(r",b", "foo,bar,baz", 6) == 8:9
312-
@test findnext(r",b", "foo,bar,baz", 10) == 0:-1
312+
@test findnext(r",b", "foo,bar,baz", 10) == nothing
313313
@test findfirst(r"az", "foo,bar,baz") == 10:11
314-
@test findnext(r"az", "foo,bar,baz", 12) == 0:-1
314+
@test findnext(r"az", "foo,bar,baz", 12) == nothing
315315

316316
# contains with a String and Char needle
317317
@test contains("foo", "o")

test/strings/types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ end
118118
# search and SubString (issue #5679)
119119
let str = "Hello, world!"
120120
u = SubString(str, 1, 5)
121-
@test findlast("World", u) == 0:-1
121+
@test findlast("World", u) == nothing
122122
@test findlast(equalto('z'), u) == nothing
123123
@test findlast("ll", u) == 3:4
124124
end

0 commit comments

Comments
 (0)