# What wrong ? range of cell fo String Array

**URL:** <https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329>\
**Category:** General Usage\
**Created:** [September 9, 2020, 1:37pm UTC](https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329 "2020-09-09T13:37:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [September 9, 2020, 1:37pm UTC](https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329/1 "2020-09-09T13:37:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [September 9, 2020, 1:40pm UTC](https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329/2 "2020-09-09T13:40:17Z")

</div>

You are missing square brackets around findall.

```julia
kody5[1][findall(rx,kody5[1])] 

```

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [September 9, 2020, 2:19pm UTC](https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329/3 "2020-09-09T14:19:40Z")

</div>

> [@dpsanders](#):
>
> `kody5[1][findall(rx,kody5[1])] `

Sorry but not works

```julia
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]

```

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [September 9, 2020, 2:20pm UTC](https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329/4 "2020-09-09T14:20:54Z")

</div>

Works like this, with spcjal

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

```

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [September 9, 2020, 2:35pm UTC](https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329/5 "2020-09-09T14:35:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [September 9, 2020, 2:35pm UTC](https://discourse.julialang.org/t/what-wrong-range-of-cell-fo-string-array/46329/6 "2020-09-09T14:35:28Z")

</div>

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