Skip to content

Commit

Permalink
Add findlast and findprev examples to strings.md manual (#29019)
Browse files Browse the repository at this point in the history
(cherry picked from commit e20d1ee)
  • Loading branch information
royalbhati authored and KristofferC committed Oct 19, 2018
1 parent e7aef94 commit f1d4dde
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
the functions [`findnext`](@ref) and [`findprev`](@ref):

```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 f1d4dde

Please sign in to comment.