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

snowflake.snowpark.functions.regexp_replace¶

snowflake.snowpark.functions.regexp_replace(subject: ColumnOrName, pattern: ColumnOrLiteralStr, replacement: ColumnOrLiteralStr = '', position: Column | int = 1, occurrences: Column | int = 0, *parameters: ColumnOrLiteral) → Column[source]¶

Returns the subject with the specified pattern (or all occurrences of the pattern) either removed or replaced by a replacement string. If no matches are found, returns the original subject.

Example::
>>> df = session.create_dataframe(
...     [["It was the best of times, it was the worst of times"]], schema=["a"]
... )
>>> df.select(regexp_replace(col("a"), lit("( ){1,}"), lit("")).alias("result")).show()
--------------------------------------------
|"RESULT"                                  |
--------------------------------------------
|Itwasthebestoftimes,itwastheworstoftimes  |
--------------------------------------------
Copy