none
Powershell "-ireplace"

    Soru

  • Hi

    In this example I am trying to use –ireplace to search for a
    string and replace it. The second example fails. I suspect I should escape the
    backslash but in reality the strings are not set my a variable declaration but
    programmatically reading a folder from a disk. Is this a regular expression
    issue?

    Thanks for any help

    #This works, the replacement is correct, even though the case is different

    $a = "OldDriveLetter Colon Backslash FileName"

    $b = "NewDriveLetter Colon"

    $c = "OldDriveLETTER Colon"

    $e = $a -ireplace $c, $b

    Write-Host $e

    #This does not work

    $a = "a:\filename"

    $b = "d:\"

    $c = "a:\"

    $e = $a -ireplace $c, $b

    Write-Host $e

    31 Mart 2012 Cumartesi 23:24

Yanıtlar

Tüm Yanıtlar