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, NaTType, float64, list, tuple, dict]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L3207-L3240)¶
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 | --------------------------------------------