Skip to content

Commit

Permalink
Include examples for findlast, findprev in the manual section about s…
Browse files Browse the repository at this point in the history
…trings.
  • Loading branch information
royalbhati authored and fredrikekre committed Sep 14, 2018
1 parent 2e603aa commit 27e0e0a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions doc/src/manual/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,20 +617,21 @@ julia> "1 + 2 = 3" == "1 + 2 = $(1 + 2)"
true
```

You can search for the index of a particular character using the [`findfirst`](@ref) function:
You can search for the index of a particular character using the
[`findfirst`](@ref) and [`findlast`](@ref) functions:

```jldoctest
julia> findfirst(isequal('x'), "xylophone")
1
julia> findfirst(isequal('o'), "xylophone")
4
julia> findfirst(isequal('p'), "xylophone")
5
julia> findlast(isequal('o'), "xylophone")
7
julia> findfirst(isequal('z'), "xylophone")
```

You can start the search for a character at a given offset by using [`findnext`](@ref)
with a third argument:
You can start the search for a character at a given offset by using
[`findnext`](@ref) and [`findprev`](@ref) with a three arguments:

```jldoctest
julia> findnext(isequal('o'), "xylophone", 1)
Expand All @@ -639,6 +640,9 @@ julia> findnext(isequal('o'), "xylophone", 1)
julia> findnext(isequal('o'), "xylophone", 5)
7
julia> findprev(isequal('o'), "xylophone", 5)
4
julia> findnext(isequal('o'), "xylophone", 8)
```

Expand Down

0 comments on commit 27e0e0a

Please sign in to comment.