PowerTip: Use PowerShell Split Operator to Break Strings

PowerTip: Use PowerShell Split Operator to Break Strings

  • Comments 3
  • Likes

Summary: Learn how to use the Windows PowerShell Split operator to break up strings.

Hey, Scripting Guy! Question How can I use Windows PowerShell to break a string at a specific character?

Hey, Scripting Guy! Answer Use the Split operator and specify the character to split on, for example:

PS C:\> "this,is,a,string" -split ","

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • thank you

  • another option using replace method or replace operator:

    PS> "this,is,a,string".replace(',',"`n")

    this
    is
    a
    string