How to find index in String Array

How to find index in String Array

Version 0.5.0 (2016-09-19 18:14 UTC)
Official http://julialang.org/ release
x86_64-w64-mingw32

julia> userstemp
5-element Array{String,1}:
“aa”
“ab”
“ac”
“ad”
“zz”

julia> indexin(userstemp,“aa”)
ERROR: MethodError: no method matching indexin(::Array{String,1}, ::String)
Closest candidates are:
indexin(::AbstractArray{T,N}, ::AbstractArray{T,N}) at array.jl:1326

julia> in(userstemp,“aa”)
false

julia> findin(userstemp,“aa”)
0-element Array{Int64,1}

julia> findin(userstemp,‘aa’)
ERROR: syntax: invalid character literal

julia> indexin(userstemp,‘aa’)
ERROR: syntax: invalid character literal

Paul

2 Likes

find(x -> x=="aa", ["aa", "ab", "ac"]) or to just match the first findfirst(x -> x=="aa", ["aa", "ab", "ac"]).

1 Like

Thanks Fredig, but why dosen`t work findin([“aa”,“ab”,“ac”],“aa”) ?
Paul
W dniu 2017-09-15 o 12:37, Fredrik Ekre pisze:

findin(["aa", "ab"], ["aa"])