Replace

The Replace method will substitute one string value for another:

$string = 'This is the first example' 
$string.Replace('first', 'second') 

PowerShell also has a replace operator. The replace operator uses a regular expression to describe the value that should be replaced.

Regular expressions (discussed in Chapter 9, Regular Expressions) may be more difficult to work with in some cases, especially when replacing characters that are reserved in regular expressions (such as the period character, .):

$string = 'Begin the begin.' 
$string -replace 'begin.', 'story, please.' 
$string.Replace('begin.', 'story, please.') 

In these cases, the Replace method may be easier to work with.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.152.251