replace

Replaces each substring that matches the literal target sequence with the specified literal replacement sequence.

Note: The replace string method is case sensitive.

Syntax:

$[ScriptVariable]::replace(String target, String replacement)

Parameters:

Examples:

The following examples illustrate the syntax for the replace string method:

Example 1

$str1 = "AQA"

$str1::replace("A", "B")

print($str1)

Output:

BQB

Example 2

$str2 = "Hello World"

$str2::replace("Hello", "Goodbye")

print($str2)

Output:

Goodbye World