# A couple of questions about arrays and "findall" function

**URL:** https://discourse.julialang.org/t/a-couple-of-questions-about-arrays-and-findall-function/68785
**Category:** New to Julia
**Tags:** strings, array
**Created:** [September 26, 2021, 7:09pm UTC](https://discourse.julialang.org/t/a-couple-of-questions-about-arrays-and-findall-function/68785 "2021-09-26T19:09:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jesus-117](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jesus-117/32/29446_2.png) [@Jesus-117](https://discourse.julialang.org/u/Jesus-117)
#### Post date: [September 26, 2021, 7:09pm UTC](https://discourse.julialang.org/t/a-couple-of-questions-about-arrays-and-findall-function/68785/1 "2021-09-26T19:09:17Z")

</div>

Hello there !! I am new to programming in general and I have a couple of questions about how to use strings, if I have an example text and I would like to count the spaces in the text like this:

```julia
ExampleText= "a b c d e f g k k k"
count(i->(i==' '), ExampleText)

```

And it works!!!,  
But researching the documentation I found the function “findall” my first question is whether  
Can I count spaces using this function?  
And the second question is if I want to make an array that contains as elements each of the words of the text. That is:  
text [1] = a, text [2] = b, … text [end] = k.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [September 26, 2021, 7:16pm UTC](https://discourse.julialang.org/t/a-couple-of-questions-about-arrays-and-findall-function/68785/2 "2021-09-26T19:16:39Z")

</div>

> [@Ixe117](#):
>
> Can I count spaces using this function?

Yes, but using `count` will be faster. BTW, shouldn’t your code say `count(i->(i==' '), ExampleText)`? Perhaps a slightly more elegant call would be

```julia
count(isspace, ExampleText)

```

where detects various whitespace.

For your second question, use `split`:

```julia
jl> split(ExampleText)
10-element Vector{SubString{String}}:
 "a"
 "b"
 "c"
 "d"
 "e"
 "f"
 "g"
 "k"
 "k"
 "k"

```

Another alternative to `isspace` and `i->(i==' ')` is `==(' ')`.

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [September 26, 2021, 7:18pm UTC](https://discourse.julialang.org/t/a-couple-of-questions-about-arrays-and-findall-function/68785/3 "2021-09-26T19:18:42Z")

</div>

In Julia 1.7 you can use:

```julia
count(' ', string)

```

The same for findall.

---

<div class="post-metadata">

### Author: ![Jesus-117](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jesus-117/32/29446_2.png) [@Jesus-117](https://discourse.julialang.org/u/Jesus-117)
#### Post date: [September 26, 2021, 7:23pm UTC](https://discourse.julialang.org/t/a-couple-of-questions-about-arrays-and-findall-function/68785/4 "2021-09-26T19:23:40Z")

</div>

Thank you for everything! 😃
