---
title: "strFind"
canonical: "https://help.vicon.com/space/ShogunPost121/1253737935/strFind"
format: markdown
---
# Description

Tries to find a sub-string within another string, and returns the zero-based index of the first character of the sub-string in string. If the sub-string is not found, -1 is returned.

## Functional area

String

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `strFind "string" "subString" index` |

### Arguments

> Macro (scroll-tablelayout)

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `string` | string | yes | String to be searched. |
| `subString` | string | yes | Sub-string to be searched for with "string" argument. |
| `startIndex` | integer | yes | Zero-based index of the character of string to start searching at, or 0 to search from the beginning. |

### Flags

None

## Return value

integer

Returns the zero based index of the location of the first character of the sub-string found. Returns -1 if not found. 

> Macro (scroll-pagebreak)

## Examples

```plaintext
// Search for a substring
string $str = "This is some text";
int $index;
 
// Search for the word "some"
$index = `strFind $str "some" 0`;
print $index; 
// Should be 8
 
// Search for the word "texas"
$index = `strFind $str "texas" 0`;
print $index; 
// Should be -1
 
// Search for the letter "t" after the word "some"
$index = `strFind $str "t" 12`;
print $index; 
// Should be 13
```

# Additional information

## Related commands

- [strCompare](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736489)
- [strLeft](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737036)
- [strLength](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738093)
- [strMid](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737094)
- [strReplace](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736842)
- [strReverseFind](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737016)
- [strRight](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736764)
- [strTok](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253739563)
- [strTokArray](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253739862)