Using Powershell Replace funcation for first occurrence of search pattern

Forum: Powershell
Viewing 2 posts - 1 through 2 (of 2 total)
  • #225952
    Profile photo of MReddy
    MReddy
    Participant

    Is there a way to specify the first occurrence of a string like, in this instance comma, as this would work except it writes Stock after the 2nd comma also

    Get-Content c:\Invent.csv | foreach{ $_.replace(^”,”,”Stock”)}

     

    Output / ResultsĀ  :-

    25,stock,04000,stock,0
    35,stock,05000,stock,1
    45,stock,06000,stock,2
    55,stock,07000,stock,3

     

    #230554
    Profile photo of Sam Boutros
    Sam Boutros
    Participant

    Can you post sample input and sample desired result?

    nvm, I doubt you still need that 30 months later.. lol

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.