---
title: rlike
description: "rlike function in PySpark: Returns true if str matches the Java regex regexp, or false otherwise."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/functions/rlike
---

# rlike

Returns true if `str` matches the Java regex `regexp`, or false otherwise.

For the corresponding Databricks SQL function, see [`rlike` operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/rlike.md).

## Syntax

```python
from pyspark.sql import functions as dbf

dbf.rlike(str=<str>, regexp=<regexp>)
```

## Parameters

| Parameter | Type                          | Description               |
| --------- | ----------------------------- | ------------------------- |
| `str`     | `pyspark.sql.Column` or `str` | Target column to work on. |
| `regexp`  | `pyspark.sql.Column` or `str` | Regex pattern to apply.   |

## Examples

```python
from pyspark.sql import functions as dbf
df = spark.createDataFrame([("1a 2b 14m", r"(\d+)")], ["str", "regexp"])
df.select('*', dbf.rlike('str', dbf.lit(r'(\d+)'))).show()
```

```Output
+---------+------+-----------------+
|      str|regexp|RLIKE(str, (\d+))|
+---------+------+-----------------+
|1a 2b 14m| (\d+)|             true|
+---------+------+-----------------+
```
