Search This Blog

Three Ways to Split String in PowerShell

This post is to summarize three ways to split a string in PowerShell.

In the following example
$t = “1000ABC2000abc"
[regex]$rx1 = “\d+”
[regex]$rx2 = “ABC"

  • Using a regex object’s split method
    • In this method, the regex works and the match is case-sensitive

      PS > $rx1.split($t)

      ABC
      abc

      PS > $rx2.split($t)
      1000
      2000abc


  • Using a string object’s split method
    • In this method, the regex does not work and the match is case-sensitive

      PS > $t.split($rx1)
      1000ABC2000abc

      PS > $t.split($rx2)
      1000
      2000abc


  • Using a string object’s split operator
    • In this method, the regex works and the match is case-insensitive

      PS > $t -split $rx1

      ABC
      abc

      PS > $t -split $rx2
      1000
      2000

Use WinSCP to Transfer Files in vCSA 6.7

This is a quick update on my previous post “ Use WinSCP to Transfer Files in vCSA 6.5 ”. When I try the same SFTP server setting in vCSA 6.7...