---
title: regexp_like function
description: Learn the syntax of the regexp\_like function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/regexp_like
---

# `regexp_like` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 10.4 LTS and above

Returns true if `str` matches `regex`. This function is a synonym for [`rlike` operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/rlike.md).

## Syntax

```
regexp_like( str, regex )
```

## Arguments

* `str`: A `STRING` expression to be matched.
* `regex`: A `STRING` expression with a matching pattern.

## Returns

A `BOOLEAN`.

The `regex` string must be a regular expression. See [Regular expressions](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-regexp-pattern.md) for the supported syntax.

When using literals, use [`raw-literal` (`r` prefix)](https://docs.databricks.com/aws/en/sql/language-manual/data-types/string-type.md) to avoid escape character pre-processing.

## Common error conditions

* [INVALID\_PARAMETER\_VALUE.PATTERN](https://docs.databricks.com/aws/en/error-messages/invalid-parameter-value-error-class.md#pattern)

## Examples

### Test whether a string matches a pattern

```sql
> SELECT regexp_like('Databricks SQL', r'^Data');
 true

> SELECT regexp_like('Spark SQL', r'^Data');
 false
```

### Validate a simple email format

```sql
> SELECT regexp_like('alice@example.com', r'^\w+@\w+\.\w+$');
 true

> SELECT regexp_like('not-an-email', r'^\w+@\w+\.\w+$');
 false
```

### Match case-insensitively

Use the `(?i)` inline flag to ignore case.

```sql
> SELECT regexp_like('ERROR: disk full', r'(?i)error');
 true
```

### Match a literal backslash

A backslash is a regex metacharacter, so match a literal backslash with `\\`. A raw literal (`r` prefix) avoids having to also double the SQL escape character.

```sql
> SELECT regexp_like(r'%SystemDrive%\Users\John', r'%SystemDrive%\\Users.*');
 true

> SELECT regexp_like('%SystemDrive%\\Users\\John', '%SystemDrive%\\\\Users.*');
 true
```

### Invalid regex pattern

```sql
> SELECT regexp_like('abc', '[invalid');
  Error: INVALID_PARAMETER_VALUE.PATTERN
```

## Related functions

* [Regular expressions](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-regexp-pattern.md)
* [`ilike` operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/ilike.md)
* [`like` operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/like.md)
* [`regexp` operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/regexp.md)
* [`regexp_extract_all` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/regexp_extract_all.md)
* [`regexp_replace` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/regexp_replace.md)
* [`rlike` operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/rlike.md)
* [`split` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/split.md)
