-replace
replaces a (sub-string) of a string or a string array with another string. Regular expressions are possible. # Replace in ONE string # 'foo, bar and baz' -replace 'ba', 'xyz' # # foo, xyzr and xyzz # Replace in collection of strings # 'foo', 'bar', 'and', 'baz' -replace 'ba', 'xyz' # # foo # xyzr # and # xyzz # Replace with regular expressions. # Two adjacent equal letters are replaced # with the number 2 and the letter: # 'apple', 'pear', 'hello' -replace '(.)\1', '2$1' -join ', ' # # a2ple, pear, he2lo
$csv_line = 'foo;bar;baz;etc' $elems = $csv_line -split ';' $elems # # foo # bar # baz # etc # $joined = $elems -join '*' $joined # # foo*bar*baz*etc #
-join
operator can also be used to concatenate strings.