snowflake.snowpark.functions.regexp_replace

snowflake.snowpark.functions.regexp_replace(subject: Union[Column, str], pattern: Union[Column, str], replacement: Union[Column, str] = '', position: Union[Column, int] = 1, occurrences: Union[Column, int] = 0, *parameters: Union[Column, None, bool, int, float, str, bytearray, Decimal, date, datetime, time, bytes, list, tuple, dict]) 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