PowerShell Replace number in string

后端 未结 3 1268
日久生厌
日久生厌 2020-12-22 06:09

I\'m not such a regex expert and frankly I\'m trying to avoid it whenever I can.

I would like to create a new $String where the number wit

3条回答
  •  遥遥无期
    2020-12-22 06:23

    If you want to avoid the regex:

    $String = "\\Server\c$\share_1\share2_\Taget2[1] - 2014-07-29.log"
    $parts = $string.Split('[]')
    $Newstring = '{0}[{1}]{2}' -f $parts[0],(1 + $parts[1]),$parts[2]
    $Newstring
    \\Server\c$\share_1\share2_\Taget2[2] - 2014-07-29.log
    

提交回复
热议问题