You are viewing documentation about an older version (1.4.0). View latest version

snowflake.snowpark.functions.regexp_extract

snowflake.snowpark.functions.regexp_extract(value: ColumnOrLiteralStr, regexp: ColumnOrLiteralStr, idx: int) Column[source]

Extract a specific group matched by a regex, from the specified string column. If the regex did not match, or the specified group did not match, an empty string is returned.

Example:

>>> from snowflake.snowpark.functions import regexp_extract
>>> df = session.createDataFrame([["id_20_30", 10], ["id_40_50", 30]], ["id", "age"])
>>> df.select(regexp_extract("id", r"(\d+)", 1).alias("RES")).show()
---------
|"RES"  |
---------
|20     |
|40     |
---------
Copy