regexp
Renvoie vrai si str correspond à l'expression régulière Java regexp, ou faux dans le cas contraire.
Pour la fonction Databricks SQL correspondante, consultez l'opérateurregexp.
Syntaxe
Python
from pyspark.sql import functions as dbf
dbf.regexp(str=<str>, regexp=<regexp>)
parameter
parameter | Type | Description |
|---|---|---|
|
| Colonne cible sur laquelle travailler. |
|
| Modèle Regex à appliquer. |
Exemples
Python
from pyspark.sql import functions as dbf
spark.createDataFrame(
[("1a 2b 14m", r"(\d+)")], ["str", "regexp"]
).select(dbf.regexp('str', dbf.lit(r'(\d+)'))).show()
Output
+------------------+
|REGEXP(str, (\d+))|
+------------------+
| true|
+------------------+