How to Find a Specific Pattern Location in Julia Strings
Code
julia> findfirst("li", "multicolinearlity")
8:9
julia> findlast("li", "multicolinearlity")
14:15
julia> findnext("l", "multicolinearlity", 1)
3:3
julia> findnext("l", "multicolinearlity", 4)
8:8
julia> findnext("l", "multicolinearlity", 9)
14:14
julia> findfirst(r"t.+t", "multicolinearlity")
4:16
findfirst(pattern, A)
- Returns a
Range
representing the interval matchingpattern
in the stringA
. - The pattern can include regular expressions. In the last example, it finds and returns the interval from the first
t
to the lastt
.