
It also explained in detail how regular expressions can be used to replace text in a string. It covered in detail with example how multiple text can be replaced simultaneously, how hash table can be used to replace text, how string in a file can be replaced with appropriate examples. The article explained the various ways in which the string can be replaced. Thus, the article covered in detail the string replace function in PowerShell. Write-Host "splitting using multiple separators" Write-Host "generating substring using space" $teststring="my name is vignesh- am from chennai" Write-Host "generating substring using split method" MaxSubstrings: The maximum number of substrings that can be generated StrSeparator: It is character of identification to split the string $hashtable1 = ($key in $hashtable1.Keys) Write-Host "Text before replacing `n" $input1 -ForegroundColor Yellow Write-Host "Demo of replacing numbers and special characters" Write-Host "After replacement" $input -ForegroundColor Yellow $input = $input.Replace($key, $hashtable.$key) #iterate the input string and replace the values Write-Host "The hashtable values are as follows `n" $hashtable.Values -ForegroundColor Yellow $hashtable = "The hashtable keys are as follows `n" $hashtable.Keys -ForegroundColor Yellow Write-Host "Text before replacing `n" $input -ForegroundColor Yellow Write-Host "Welcome to demo of replace using hashtable"

The values of a hash table can be altered as follows. In the case of replacing text using hash table, the key would represent the text to be replaced and the value would represent the text value to be used for replacement. The built-in properties of a hash table are key, value and count. The key values must be unique, and values can be non-unique. Hash table is a type of an array, which stores values as key value pair. The other effective way of replacing multiple text simultaneously would be to use hash table.

$actual="Australia won the world cup in 1999" Write-Host "Demo of multiple replace simultaneosly" Write-Host "The below will replace this with that" Write-Host "Replace using replace function"
#String replacer windows code
Write-Host "The below code will replace vignesh with Viki" Write-Host "Actual text before replace is" $input Write-Host "Demo of single text replacement" Write-Host "Welcome to Replace function demo in PowerShell"
