doc-exports/docs/dli/sqlreference/dli_spark_replace.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-03-27 22:02:33 +00:00

6.4 KiB

replace

This function is used to replace the part in a specified string that is the same as the string old with the string new and return the result.

If the string has no same characters as the string old, str is returned.

Syntax

replace(string <str>, string <old>, string <new>)

Parameters

Table 1 Parameters

Parameter

Mandatory

Type

Description

str

Yes

STRING

String to be replaced

old

Yes

STRING

String to be compared

new

Yes

STRING

String after replacement

Return Values

The return value is of the STRING type.

If the value of any input parameter is NULL, NULL is returned.

Example Code

The value AA123AA is returned.

select replace('abc123abc','abc','AA');

The value NULL is returned.

select replace('abc123abc',null,'AA');