String.replace()

Signature

String replace (String s1, char oldChar, char newChar)

Domain

ACTION, CONDITION, QUERY

Description

Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar. If the character oldChar does not occur in the character sequence represented by this String object, then a reference to this String object is returned. Otherwise, a new String object is created that represents a character sequence identical to the character sequence represented by this String object, except that every occurrence of oldChar is replaced by an occurrence of newChar.

Parameters

NameTypeDescription
s1StringA String to replace characters in.
oldCharcharThe old char to replace in the String s1.
newCharcharThe new char to replace the old char with, in the String s1.

Returns

TypeDescription
StringA string derived from the String s1 by replacing every occurrence of oldChar with newChar.

Cautions

none