Modify variable

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 9 months ago.

  • Author
    Posts
  • #5746

    by leitsu at 2013-04-01 16:56:35

    Hi
    How do I modify a variable. Thats say I have a variable $var = "ABC EFG". How do I check if there is a space in the variable and replace the space with "-"? $var = "ABC-EFG"

    by Nobody at 2013-04-01 19:30:32

    Use the "Replace" method


    $a = "ABC EFG"
    $a = $a.replace(" ","-")

    Lots of other string methods available too! Pipe the string to Get-Member and have a look


    "my string"|Get-Member

You must be logged in to reply to this topic.