---
title: "strLeft"
canonical: "https://help.vicon.com/space/ShogunPost120/1043038597/strLeft"
format: markdown
---
# Description

Extracts the first (left-most) "count" characters from "string". If "count" is greater than the length of string, the entire string is returned.

## Functional area

String

# Command syntax

## Syntax

|  |
| --- |
| `strLeft "string" count` |

### Arguments

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `string` | string | yes | String to extract sub-string from. |
| `count` | integer | yes | The number of characters to extract from string, counting from the left. |

### Flags

None

## Return value

string

Returns the sub-string from "string". 

> Macro (scroll-pagebreak)

## Examples

```plaintext
// Extract some substrings
string $str = "This is some text";
string $subStr;
 
// Extract the first 7 characters
$subStr = `strLeft $str 7`;
print $subStr; 
// Should be "This is"
 
// Extract the first 17 characters
$subStr = `strLeft $str 17`;
print $subStr; 
// Should be same as $str
```

# Additional information

## Related commands

- [strCompare](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043038406)
- [strFind](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043038952)
- [strLength](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039138)
- [strMid](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043041505)
- [strReplace](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039663)
- [strReverseFind](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039601)
- [strRight](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043040073)
- [strTok](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039379)
- [strTokArray](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043040732)