Replace operator:
The -replace
operator replaces a pattern in an input value using a regular expression. This operator uses two arguments (separated by a comma): a regular expression pattern and its replacement value (which is optional and an empty string by default).
"The rain in Seattle" -replace 'rain','hail' #Returns: The hail in Seattle
"[email protected]" -replace '^[\w]+@(.+)', '$1' #Returns: contoso.com
Split and Join operators:
The -split
operator splits a string into an array of sub-strings.
"A B C" -split " " #Returns an array string collection object containing A,B and C.
The -join
operator joins an array of strings into a single string.
"E","F","G" -join ":" #Returns a single string: E:F:G