Skip to content

Commit 10def15

Browse files
josobarKristofferC
authored andcommitted
regex.jl: add new doctests for findall (#34271)
1 parent e09066f commit 10def15

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

base/regex.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,23 @@ matching sequence is found, like the return value of [`findnext`](@ref).
340340
341341
If `overlap=true`, the matching sequences are allowed to overlap indices in the
342342
original string, otherwise they must be from disjoint character ranges.
343+
344+
# Examples
345+
```jldoctest
346+
julia> findall("a", "apple")
347+
1-element Array{UnitRange{Int64},1}:
348+
1:1
349+
350+
julia> findall("nana", "banana")
351+
1-element Array{UnitRange{Int64},1}:
352+
3:6
353+
354+
julia> findall("a", "banana")
355+
3-element Array{UnitRange{Int64},1}:
356+
2:2
357+
4:4
358+
6:6
359+
```
343360
"""
344361
function findall(t::Union{AbstractString,Regex}, s::AbstractString; overlap::Bool=false)
345362
found = UnitRange{Int}[]

0 commit comments

Comments
 (0)