# Count
{: .no_toc }

Returns the number of [**Match**](/tB/Packages/Contributed/tbRegExp/Match/index.md) objects in the collection.

Syntax: *object*.**Count**

*object*
: *required* An object expression that evaluates to a **MatchCollection**.

Returns a **Long**. The property is read-only.

## Remarks

For the collection that the **Execute** method of [**RegExp**](/tB/Packages/Contributed/tbRegExp/RegExp/index.md) returns, **Count** is the number of matches found in the source string. It is 0 when the pattern finds nothing. When the **Global** property of the expression is **False**, the collection holds the first match only, so **Count** is at most 1.

The positions that [**Item**](/tB/Packages/Contributed/tbRegExp/MatchCollection/Item.md) accepts run from 0 to **Count** - 1.

## Example

```tb check_build check_run
Dim re As New RegExp
re.Pattern = "[a-z]+"
re.Global = True
Debug.Print re.Execute("one two three").Count  ' 3
Debug.Print re.Execute("1 2 3").Count          ' 0

re.Global = False
Debug.Print re.Execute("one two three").Count  ' 1
```

## See Also

- [Item](/tB/Packages/Contributed/tbRegExp/MatchCollection/Item.md) property -- returns a match by position
- [MatchCollection](/tB/Packages/Contributed/tbRegExp/MatchCollection/index.md) class -- overview
