replace()

Read(3530) Label: replace, source string, substring,

Description:

Replace a specified substring of a source string.

Syntax:

replace (src,a,b)

Note:

The function replaces substring a of string src with string b. When parameters a and b are sequences, replace members of a with corresponding members of b.

Parameter:

src

Source string

a

A substring of the source string, or a sequence of substrings

b

The string or a sequence of strings with which the specified substring will be replaced

Option:

@q

A quoted specified string won’t be replaced

@1

Enable to replace the first-found specified substring only

@c

Case-insensitive

@s

Split content of a and b respectively into a sequence and perform the replacement correspondingly

@w

Only replace the substring with the same number of characters

Return value:

String

Example:

replace("123321","2","two")

1two33two1.

replace("abc'abc'def","a","China")

Chinabc'Chinabc'def.

replace@q("abc'abc'def","a","China")

Chinabc'abc'def; the “a” enclosed by the single quotes are not replaced.

replace@1("abcabcdef","a","China")

Chinabcabcdef; only the first “a” is replaced.

replace@c("abcabcdef","A","China")

ChinabcChinabcdef; case-insensitive.

replace("1212341",["1","2"],["8","9"])

8989348.

replace@s("1212341","12","89")

8989348.

replace("aaa,aab,aa","aa","AA")

Return AAa,AAb,AA.

replace@w("aaa,aab,aa","aa","AA")

Use @w option to replace the substring having the same number of characters only; here the function return aaa,aab,AA: