メインコンテンツまでスキップ

正規表現入力文字列

Java 正規表現regexpに一致し、正規表現グループ インデックスに対応するstr内の最初の部分文字列の位置を返します。

対応する Databricks SQL 関数については、 regexp_instr関数を参照してください。

構文

Python
from pyspark.databricks.sql import functions as dbf

dbf.regexp_instr(str=<str>, regexp=<regexp>, idx=<idx>)

パラメーター

パラメーター

Type

説明

str

pyspark.sql.Column または str

取り組むターゲットカラム。

regexp

pyspark.sql.Column または str

適用する正規表現パターン。

idx

pyspark.sql.Column または int, optional

一致したグループ ID。

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