Skip to main content

rlike

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

For the corresponding Databricks SQL function, see rlike operator.

Syntax

Python
from pyspark.databricks.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.databricks.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|
+---------+------+-----------------+