Returns the position (1-based) of the substring that matches the regular expression. Returns 0 if there is no match.
INT64Diperbarui: 13 Jun 2026REGEXP_INSTR(source_value, regexp [, position [, occurrence [, occurrence_position]]])The string to search
Regular expression pattern
Starting position for the search
Default: 1
The nth occurrence to locate
Default: 1
0 = start of match, 1 = end of match
Default: 0
1 SELECT 2 text, 3 REGEXP_INSTR(text, r'[0-9]+') as number_pos 4 FROM `project.dataset.data`;
Find the position of the first number.
| text | number_pos |
|---|---|
| abc123def | 4 |
| no numbers | 0 |
1 SELECT 2 REGEXP_INSTR('abc123def456', r'[0-9]+', 1, 2) as second_num_pos;
Position of the second occurrence of the pattern.
1 SELECT 2 REGEXP_INSTR('abc123def', r'[0-9]+', 1, 1, 1) as after_number;
Position immediately after the match ends.
Sudah paham REGEXP_INSTR? Latih langsung di browser
Latihan interaktif, langsung di browser.