Substring(子字符串(Substring))¶
Supported in: Batch, Faster, Streaming
Extract substring.
Expression categories: Numeric
Declared arguments¶
- Expression: Expression to extract substring from.
Expression\ - Start: The index to start substring from (inclusive). Negative numbers start from end of string. This is 1-indexed.
Expression\ - optional Length: The length of the substring to extract. If not provided the remainder of the string is extracted.
Expression\
Output type: String
Examples¶
Example 1: Base case¶
Argument values:
- Expression:
string - Start:
start - Length:
length
| string | start | length | Output |
|---|---|---|---|
| hello, world | 1 | 5 | hello |
| hello, world | 8 | 5 | world |
| hello, world | -5 | 5 | world |
Example 2: Base case¶
Description: When no length is provided, the substring runs to end of string.
Argument values:
- Expression:
string - Start:
start - Length: null
| string | start | Output |
|---|---|---|
| hello, world | 1 | hello, world |
| hello, world | 8 | world |
| hello, world | -5 | world |
Example 3: Null case¶
Description: In case of nulls, the output is always null.
Argument values:
- Expression:
string - Start:
start - Length:
length
| string | start | length | Output |
|---|---|---|---|
| null | 1 | 5 | null |
| hello, world | null | 5 | null |
| hello, world | 1 | null | null |
| null | null | null | null |
Example 4: Edge case¶
Description: When length is longer than remaining sub string, the output is the sub string until the end of the string.
Argument values:
- Expression:
string - Start:
start - Length:
length
| string | start | length | Output |
|---|---|---|---|
| hello, world | -5 | 10 | world |
| hello, world | 1 | 20 | hello, world |
| hello, world | 12 | 5 | d |
| hello, world | 13 | 5 | empty string |
| hello, world | 20 | 5 | empty string |
| hello, world | 12 | -5 | empty string |
中文翻译¶
子字符串(Substring)¶
支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)
提取子字符串。
表达式类别: 数值型(Numeric)
声明的参数¶
- 表达式(Expression): 要从中提取子字符串的表达式。
表达式\<字符串> - 起始位置(Start): 子字符串的起始索引(包含)。负数表示从字符串末尾开始计数。此为从1开始索引。
表达式\<整数> - 可选 长度(Length): 要提取的子字符串长度。若未提供,则提取字符串的剩余部分。
表达式\<整数>
输出类型: 字符串(String)
示例¶
示例1:基础情况¶
参数值:
- 表达式(Expression):
string - 起始位置(Start):
start - 长度(Length):
length
| string | start | length | 输出(Output) |
|---|---|---|---|
| hello, world | 1 | 5 | hello |
| hello, world | 8 | 5 | world |
| hello, world | -5 | 5 | world |
示例2:基础情况¶
描述: 当未提供长度时,子字符串将一直提取到字符串末尾。
参数值:
- 表达式(Expression):
string - 起始位置(Start):
start - 长度(Length): null
| string | start | 输出(Output) |
|---|---|---|
| hello, world | 1 | hello, world |
| hello, world | 8 | world |
| hello, world | -5 | world |
示例3:空值情况¶
描述: 若存在空值,输出始终为空。
参数值:
- 表达式(Expression):
string - 起始位置(Start):
start - 长度(Length):
length
| string | start | length | 输出(Output) |
|---|---|---|---|
| null | 1 | 5 | null |
| hello, world | null | 5 | null |
| hello, world | 1 | null | null |
| null | null | null | null |
示例4:边界情况¶
描述: 当长度超过剩余子字符串时,输出将提取到字符串末尾为止的子字符串。
参数值:
- 表达式(Expression):
string - 起始位置(Start):
start - 长度(Length):
length
| string | start | length | 输出(Output) |
|---|---|---|---|
| hello, world | -5 | 10 | world |
| hello, world | 1 | 20 | hello, world |
| hello, world | 12 | 5 | d |
| hello, world | 13 | 5 | 空字符串(empty string) |
| hello, world | 20 | 5 | 空字符串(empty string) |
| hello, world | 12 | -5 | 空字符串(empty string) |