regexp_instr1
Calculates the starting or ending position of the substring in source that matches pattern for the occurrence-th time, starting from start_position.
Syntax
regexp_instr1(string <source>, string <pattern>[, bigint <start_position>[, bigint <occurrence>[, bigint <return_option>]]])
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| source | Yes | STRING | The source string. |
| pattern | Yes | STRING | The regular expression. The pattern to be matched. An error is returned if pattern is an empty string. |
| start_position | No | BIGINT | The starting position for the search. When not specified, the default value is 1. |
| occurrence | No | BIGINT | Specifies the occurrence count. When not specified, the default value is 1, meaning the first occurrence is searched. |
| return_option | No | BIGINT | Specifies the type of position to return. Valid values are 0 or 1. When not specified, the default value is 0. 0 indicates returning the starting position of the match, and 1 indicates returning the ending position of the match. |
Return Values
Returns a value of type BIGINT. return_option specifies whether the starting or ending position of the matched substring in source is returned.
- If pattern is an empty string, an error is reported.
- If start_position or occurrence is not of type BIGINT or is less than or equal to 0, an error is returned.
- If source, pattern, start_position, occurrence, or return_option is NULL, NULL is returned.
Example Code
Returns 6.
select regexp_instr1('a1b2c3d4', '[0-9]', 3, 2); Returns NULL.
select regexp_instr1('a1b2c3d4', null, 3, 2); What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot