Split and Join OperatorsThe Split and Join operators are used in PowerShell to divide and combine the substrings. -Join OperatorThe -Join operator is used in PowerShell to combine the set of strings into a single string. The strings are combined in the same order in which they appear in the command. The following two statements are the syntax to use the Join operator: In the above syntax, the <String> parameter is used to specify the one or more strings to be joined. And the <Delimiter> parameter is used to specify one or more characters placed between the combined strings. The default Delimiter is " ". Note: If we use the unary join operator (-join <String>) to combine the strings, we must enclose them in parenthesis, or store them in a variable.Examples: The below examples describe how to use the unary and binary (With Delimiter) Join operator in different ways: Example1: The command in this example displays the following output: Windows Operating System Example2: The command in this example displays the following output: WindowsOperatingSystem Example3: The second command in this example displays the following output: WindowsOperatingSystem Example4: This example uses the multiple-character delimiter to join the three strings, which are stored in the variable $x. The second command in this example displays the following output: WINDOWS POWERSHELL -Split OperatorThe -Split operator is used in PowerShell to divide the one or more strings into the substrings. The following statements are the syntax to use the -split operator: In the above Syntax, the following parameters are used:
Examples: The following examples describe how to use the -split operator in different ways: Example 1: This command displays the following output: a b c d e f g h Example2: The output of this example is the same as the output of example1. Example3: The output of this example is also same as the output of example1. Example4: This example displays the following output: a b c=d=e=f=g=h Example5: This example displays the following output: a= =c=d=e= =g=h Next TopicIf Statement |