PS: String/Text Replacement
PS supports a built-in string search and replacement operator named –replace. The -replace operator uses a regular expression to search-and-replace through a string. The default behavior is it does a case insensitive similar to that of using –ireplace. For a case sensitiveness, you need to use –creplace. Default replace behavior: PS C:> $str = "This is a SAMPLE string" PS C:> write-host $Str This is a SAMPLE string PS C:> $str -replace "SAMple","Test" This is a Test string PS C:> write-host $Str This is a SAMPLE string PS C:> Explicit case-insensitive replacement: PS C:> write-host $Str This is a SAMPLE […]
Read more