# substr

`substr` has 1 variant:

{% tabs %}
{% tab title="Variant 1" %}
#### Description <a href="#description" id="description"></a>

&#x20;`substr` functions allows you to extract a substring from a string.

* If start\_position is 0, then the SUBSTR function treats start\_position as 1 (ie: the first position in the string).
* If start\_position is a positive number, then the SUBSTR function starts from the beginning of the string.
* If start\_position is a negative number, then the SUBSTR function starts from the end of the string and counts backwards.
* If length is a negative number, then the SUBSTR function will return a NULL value.

#### Declaration <a href="#declaration" id="declaration"></a>

```
char substr(char string, int startPosition, int length);
```

#### Parameters <a href="#parameters" id="parameters"></a>

#### Return Value <a href="#return-value" id="return-value"></a>

#### Example <a href="#example" id="example"></a>

```
char str;
str = substr("This is a test", 6, 2);
```

Result: "is"

#### See also <a href="#see-also" id="see-also"></a>
{% endtab %}
{% endtabs %}
