# count() function

The count() function returns the number
of occurrences of str.exp2 within str.exp1.

## Syntax

```
count(str.exp1, str.exp2)
```

## Parameter(s)

| str.exp1 | Specifies the string expression in which to search for occurrences of str.exp2. |
| --- | --- |
| str.exp2 | Specifies the string expression to locate within str.exp1. |

## Example(s)

This displays the number of spaces
in the string held in the variable `sentence`, which is equal to 3.

```
sentence = "sam is home alone"
print count(sentence,’ ’)
```

## See also

- [dcount() function](https://d3codex.com/pickbasic-flashbasic/dcount-function/)
- [fold() function](https://d3codex.com/pickbasic-flashbasic/fold-function/)
- [BASIC functions](https://d3codex.com/pickbasic-flashbasic/basic-functions/)
- [occurs() function](https://d3codex.com/pickbasic-flashbasic/occurs-function/)
- [procread statement](https://d3codex.com/pickbasic-flashbasic/procread-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [String expressions](https://d3codex.com/pickbasic-flashbasic/string-expressions/)

---
Source: https://d3codex.com/pickbasic-flashbasic/count-function/ - part of the D3Codex reference.
