# Regular Expression Match Operators

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

Operators for matching strings against regular expression patterns. Regular expressions provide more powerful pattern matching than `LIKE`.

## Syntax

```sql
<string> ~ <pattern>
<string> ~* <pattern>
<string> !~ <pattern>
<string> !~* <pattern>
```

## Operators

| Operator | Description                                        |
| :------- | :------------------------------------------------- |
| `~`      | Matches regular expression, case-sensitive         |
| `~*`     | Matches regular expression, case-insensitive       |
| `!~`     | Doesn't match regular expression, case-sensitive   |
| `!~*`    | Doesn't match regular expression, case-insensitive |

## Arguments

### Required

- `<string>`: The string to match against.
- `<pattern>`: The regular expression pattern.

## Returns

Returns a boolean value indicating whether the string matches (or does not match) the pattern.

## Considerations

- Regular expressions are more powerful than `LIKE` patterns, supporting complex patterns like repetition, alternation, and character classes.
- Unlike `LIKE`, regular expressions match anywhere within the string by default. Use `^` and `$` anchors to match the start and end of the string.
- For detailed regex syntax, see [Regular Expression Syntax](/docs/data/data-cloud-query-guide/references/dc-sql-reference/string-matching.md#regular-expression-syntax).

## Examples

### Case-Sensitive Match

Match a pattern with case sensitivity.

```sql
SELECT 'thomas' ~ '.*thomas.*' AS result;
```

Returns `true`.

```sql
SELECT 'thomas' ~ '.*Thomas.*' AS result;
```

Returns `false` because case does not match.

### Case-Insensitive Match

Match a pattern ignoring case.

```sql
SELECT 'thomas' ~* '.*Thomas.*' AS result;
```

Returns `true`.

### Negated Match

Check that a string does not match a pattern.

```sql
SELECT 'thomas' !~ '.*Thomas.*' AS result;
```

Returns `true` because case-sensitive match fails.

```sql
SELECT 'thomas' !~* '.*vadim.*' AS result;
```

Returns `true` because the pattern is not found.

### Alternation

Match one of multiple patterns.

```sql
SELECT 'abc' ~ '(b|d)' AS result;
```

Returns `true` because the string contains 'b'.

### Start of String

Match patterns at the beginning of a string.

```sql
SELECT 'abc' ~ '^a' AS result;
```

Returns `true` because the string starts with 'a'.

```sql
SELECT 'abc' ~ '^(b|c)' AS result;
```

Returns `false` because the string does not start with 'b' or 'c'.

## Related Documentation

- [LIKE / ILIKE](/docs/data/data-cloud-query-guide/references/dc-sql-reference/like.md)
- [REGEXP_LIKE](/docs/data/data-cloud-query-guide/references/dc-sql-reference/regexp-like.md)
- [Regular Expression Syntax](/docs/data/data-cloud-query-guide/references/dc-sql-reference/string-matching.md#regular-expression-syntax)
