# SUBSTRING

从给定字符串中的指定点提取子字符串。

这是 [`SUBSTR`](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/DataIntegration/Lakehouse/TransformationFunctions/string/substr.htm) 函数的别名。

## 语法

```
SUBSTRING(STRING, START [, LENGTH])
```

## 参数

#### STRING

类型：`string`

要从中提取子字符串的字符串。

#### START

类型：`integer`

子字符串的起始索引。

位置从 `1` 开始。负起始位置被解释为相对于字符串的末尾。

#### LENGTH

类型：`integer`

(可选) 子字符串的长度。

如果省略，则返回起始位置 `START` 之后字符串的其余部分。

## 返回

类型：`string`

从 `STRING` 的起始位置 `START` 返回长度为 `LENGTH` 的子字符串。

***

## 示例

| STRING | START | LENGTH | 输出 |
| --- | --- | --- | --- |
| 你好世界 | 1 | 5 | 你好 |
| 你好世界 | 0 | 4 | `''` |
| 你好世界 | -5 | 5 | 世界 |
| 你好世界 | 12 | 4 | `''` |
| 你好世界 | -12 | 4 | `''` |
| 你好世界 | 2 | 3 | 埃尔 |
| 你好世界 | 3 | -2 | `''` |
| 你好世界 | 2 | 14 | 你好世界 |
| 你好世界 | 2 |  | 你好世界 |
| 你好世界 | -3 | 2 | rl |
| `null` | -3 | 2 | `null` |