---
title: "strFind"
canonical: "https://help.vicon.com/space/ShogunPost116/341120455/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

|  |
| --- |
| `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/ShogunPost116/pages/341120449)
- [strLeft](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120461)
- [strLength](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120467)
- [strMid](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120473)
- [strReplace](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120479)
- [strReverseFind](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120485)
- [strRight](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120491)
- [strTok](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120497)
- [strTokArray](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost116/pages/341120503)