What wrong ? range of cell fo String Array

julia> kody5[1]
"orbis sa 00-028 ul bracka 16 oddzial hotel aria w sosnowcu"

julia> findall(rx,kody5[1])
1-element Array{UnitRange{Int64},1}:
 10:15

julia> kody5[1]findall(rx,kody5[1])
ERROR: MethodError: no method matching *(::String, ::Array{UnitRange{Int64},1})
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:538

julia>  kody5[1][10:15]
"00-028"

Paul

You are missing square brackets around findall.

kody5[1][findall(rx,kody5[1])] 
1 Like

Sorry but not works

julia> kody5[1][findall(rx,kody5[1])]
ERROR: MethodError: no method matching getindex(::String, ::Array{UnitRange{Int64},1})
Closest candidates are:
  getindex(::String, ::UnitRange{Int64}) at strings/string.jl:244
  getindex(::String, ::Int64) at strings/string.jl:209
  getindex(::String, ::UnitRange{var"#s91"} where var"#s91"<:Integer) at strings/string.jl:242
  ...
Stacktrace:
 [1] top-level scope at REPL[123]:1

julia> kody5[1]
"orbis sa 00-028 ul bracka 16 oddzial hotel aria w sosnowcu"

julia> [findall(rx,kody5[1])]
1-element Array{Array{UnitRange{Int64},1},1}:
 [10:15]

Works like this, with spcjal

julia> kody5[1][findall(rx,kody5[1])[]]
"00-028"

You are using findall, findall will always return a vector with all ranges, by using [] you are now getting only the first range, are you sure this is what you want? If this is what you want you should just use findfirst instead of findall.

Yes, sorry, it’s an array so you need to extract an element.