# `REGEXP_INSTR`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Returns the position of the first substring matching a regular expression pattern.

## Syntax

```sql
regexp_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.

```sql
SELECT regexp_instr('abc123def', '\d+') AS result;
```

Returns `4`, the position where digits begin.

### No Match

Returns `0` when pattern is not found.

```sql
SELECT regexp_instr('abcdef', '\d+') AS result;
```

Returns `0`.

### Find Word Position

Find the position of a word pattern.

```sql
SELECT regexp_instr('The quick brown fox', 'brown') AS result;
```

Returns `11`.

### Use in Filtering

Filter rows based on pattern position.

```sql
SELECT code FROM products
WHERE regexp_instr(code, '^[A-Z]{2}') = 1;
```

Returns products where code starts with two uppercase letters.

## Related Documentation

- [POSITION](/docs/data/data-cloud-query-guide/references/dc-sql-reference/position.md)
- [STRPOS](/docs/data/data-cloud-query-guide/references/dc-sql-reference/strpos.md)
- [REGEXP_SUBSTR](/docs/data/data-cloud-query-guide/references/dc-sql-reference/regexp-substr.md)
- [Regular Expression Syntax](/docs/data/data-cloud-query-guide/references/dc-sql-reference/string-matching.md#regular-expression-syntax)
