2025-03-06 23:58:30 +08:00
|
|
|
% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
|
|
|
|
|
|
|
|
**Examples**
|
|
|
|
|
|
|
|
This example returns the first three characters of every last name:
|
|
|
|
|
|
|
|
```esql
|
|
|
|
FROM employees
|
|
|
|
| KEEP last_name
|
|
|
|
| EVAL ln_sub = SUBSTRING(last_name, 1, 3)
|
|
|
|
```
|
|
|
|
|
|
|
|
| last_name:keyword | ln_sub:keyword |
|
|
|
|
| --- | --- |
|
|
|
|
| Awdeh | Awd |
|
|
|
|
| Azuma | Azu |
|
|
|
|
| Baek | Bae |
|
|
|
|
| Bamford | Bam |
|
|
|
|
| Bernatsky | Ber |
|
|
|
|
|
2025-03-14 03:33:18 +08:00
|
|
|
A negative start position is interpreted as being relative to the end of the string.
|
|
|
|
This example returns the last three characters of every last name:
|
2025-03-06 23:58:30 +08:00
|
|
|
|
|
|
|
```esql
|
|
|
|
FROM employees
|
|
|
|
| KEEP last_name
|
|
|
|
| EVAL ln_sub = SUBSTRING(last_name, -3, 3)
|
|
|
|
```
|
|
|
|
|
|
|
|
| last_name:keyword | ln_sub:keyword |
|
|
|
|
| --- | --- |
|
|
|
|
| Awdeh | deh |
|
|
|
|
| Azuma | uma |
|
|
|
|
| Baek | aek |
|
|
|
|
| Bamford | ord |
|
|
|
|
| Bernatsky | sky |
|
|
|
|
|
2025-03-14 03:33:18 +08:00
|
|
|
If length is omitted, substring returns the remainder of the string.
|
|
|
|
This example returns all characters except for the first:
|
2025-03-06 23:58:30 +08:00
|
|
|
|
|
|
|
```esql
|
|
|
|
FROM employees
|
|
|
|
| KEEP last_name
|
|
|
|
| EVAL ln_sub = SUBSTRING(last_name, 2)
|
|
|
|
```
|
|
|
|
|
|
|
|
| last_name:keyword | ln_sub:keyword |
|
|
|
|
| --- | --- |
|
|
|
|
| Awdeh | wdeh |
|
|
|
|
| Azuma | zuma |
|
|
|
|
| Baek | aek |
|
|
|
|
| Bamford | amford |
|
|
|
|
| Bernatsky | ernatsky |
|
|
|
|
|
|
|
|
|