Remove Space- Join Words

Welcome Forums General PowerShell Q&A Remove Space- Join Words

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
4 years, 3 months ago.

  • Author
    Posts
  • #18697

    Participant
    Points: 0
    Rank: Member

    I am using import-csv, and one of the columns have a 3 word result set (Post University Online) in the $_.name column.

    I would like to join all three words so there is no space using this syntax select-object @{n='Name';e={$_.name}}

    any help with the method that may accomplish this would be greatly appreciated.

  • #18700

    Participant
    Points: 53
    Rank: Member

    Give this a try:

    Select-Object -Property @{name='Name';expression={$_.name -replace '\s'}}

  • #18702

    Participant
    Points: 0
    Rank: Member

    perfect! thanks Mike

  • #18703

    Participant
    Points: 0
    Rank: Member

    Mike one more ? i have a field that returns a date 09/09/2010 can i replace the "/" with a "-"

    heres what i have so far

    @{n='CreatedDate';e={$_.createddate.substring(0,9)}}
    (im taking out the time)

  • #18704

    Participant
    Points: 0
    Rank: Member

    i have the answer i figured it out

    import-csv $ImportFile | select @{n='CreatedDate';e={$_.createddate.substring(0,9) -replace '/','-'}}

    thanks mike for all your help

The topic ‘Remove Space- Join Words’ is closed to new replies.