Regex index(正则索引(Regex index))¶
Supported in: Batch, Faster, Streaming
Returns an array of indices (counted as Unicode code points) at which the regular expression pattern is found in the given expression.
Expression categories: Regex, String
Declared arguments¶
- Expression: The expression to match against the regular expression.
Expression\ - Regex: The regular expression to find indices for.
Expression\
Output type: Array\
Examples¶
Example 1: Base case¶
Description: You can find regex patterns and their indices.
Argument values:
- Expression: ababab
- Regex: ab
Output: [ 0, 2, 4 ]
Example 2: Base case¶
Description: Overlapping matches are not considered separately; the entire matching segment is treated as a single match.
Argument values:
- Expression: abcdcef
- Regex: .c.
Output: [ 0 ]
Example 3: Base case¶
Description: Regex patterns sometimes don't match input strings, resulting in an empty array.
Argument values:
- Expression: abdefg
- Regex: cd
Output: [ ]
Example 4: Base case¶
Argument values:
- Expression:
string - Regex:
pattern
| string | pattern | Output |
|---|---|---|
| Hello 👋 World | World | [ 8 ] |
| café123 | \d+ | [ 4 ] |
| a🎉b🎊c🎁d | [a-z] | [ 0, 2, 4, 6 ] |
| Hi_café_😀_end | end | [ 10 ] |
Example 5: Null case¶
Argument values:
- Expression:
string - Regex:
pattern
| string | pattern | Output |
|---|---|---|
| foofoo | [def | null |
| foofoo | [def] | [ 0, 3 ] |
| null | ab | null |
| null | null | null |
Example 6: Null case¶
Description: If the expression is null, the output is null.
Argument values:
- Expression: null
- Regex: ab
Output: null
Example 7: Null case¶
Description: If the pattern is null, the output is null.
Argument values:
- Expression: ababab
- Regex: null
Output: null
Example 8: Null case¶
Argument values:
- Expression:
string - Regex:
pattern
| string | pattern | Output |
|---|---|---|
| foofoo | foo | [ 0, 3 ] |
| foo | null | null |
| null | ab | null |
| null | null | null |
中文翻译¶
正则索引(Regex index)¶
支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)
返回一个索引数组(以 Unicode 码点计数),表示正则表达式模式在给定表达式中被找到的位置。
表达式类别: 正则(Regex)、字符串(String)
声明的参数¶
- 表达式(Expression): 用于匹配正则表达式的表达式。
Expression\ - 正则表达式(Regex): 用于查找索引的正则表达式。
Expression\
输出类型: Array\
示例¶
示例 1:基础情况¶
描述: 您可以查找正则表达式模式及其索引。
参数值:
- 表达式: ababab
- 正则表达式: ab
输出: [ 0, 2, 4 ]
示例 2:基础情况¶
描述: 重叠匹配不会被单独考虑;整个匹配段被视为一个匹配。
参数值:
- 表达式: abcdcef
- 正则表达式: .c.
输出: [ 0 ]
示例 3:基础情况¶
描述: 正则表达式模式有时无法匹配输入字符串,结果会返回空数组。
参数值:
- 表达式: abdefg
- 正则表达式: cd
输出: [ ]
示例 4:基础情况¶
参数值:
- 表达式:
string - 正则表达式:
pattern
| string | pattern | 输出 |
|---|---|---|
| Hello 👋 World | World | [ 8 ] |
| café123 | \d+ | [ 4 ] |
| a🎉b🎊c🎁d | [a-z] | [ 0, 2, 4, 6 ] |
| Hi_café_😀_end | end | [ 10 ] |
示例 5:空值情况¶
参数值:
- 表达式:
string - 正则表达式:
pattern
| string | pattern | 输出 |
|---|---|---|
| foofoo | [def | null |
| foofoo | [def] | [ 0, 3 ] |
| null | ab | null |
| null | null | null |
示例 6:空值情况¶
描述: 如果表达式为空,则输出为空。
参数值:
- 表达式: null
- 正则表达式: ab
输出: null
示例 7:空值情况¶
描述: 如果模式为空,则输出为空。
参数值:
- 表达式: ababab
- 正则表达式: null
输出: null
示例 8:空值情况¶
参数值:
- 表达式:
string - 正则表达式:
pattern
| string | pattern | 输出 |
|---|---|---|
| foofoo | foo | [ 0, 3 ] |
| foo | null | null |
| null | ab | null |
| null | null | null |