REGEXP_INSTR
Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Returns the position of the first substring matching a regular expression pattern.
Syntax
1regexp_instr(<string>, <pattern>)
Arguments
Required
<string>: The string to search within.
<pattern>: The regular expression pattern to find.
Returns
Returns an integer representing the one-based position of the match, or 0 if no match is found.
Examples
Find Pattern Position
Find the position of digits in a string.
1SELECT regexp_instr('abc123def', '\d+') AS result;
Returns 4, the position where digits begin.
No Match
Returns 0 when pattern is not found.
1SELECT regexp_instr('abcdef', '\d+') AS result;
Returns 0.
Find Word Position
Find the position of a word pattern.
1SELECT regexp_instr('The quick brown fox', 'brown') AS result;
Returns 11.
Use in Filtering
Filter rows based on pattern position.
1SELECT code FROM products
2WHERE regexp_instr(code, '^[A-Z]{2}') = 1;
Returns products where code starts with two uppercase letters.
Related Documentation