温馨提示:本文翻译自stackoverflow.com,查看原文请点击:PowerShell - remove first character if a specific character
powershell

PowerShell - 如果有特定字符,则删除第一个字符

发布于 2020-03-27 10:18:00
 $path = "\path\to\my\file"

我只想删除第一个\怎么做?

我不想删除第一个字符(只有字母) \

查看更多

查看更多

提问者
whoisearth
被浏览
171
gravity 2019-07-03 21:04
$path = $path.TrimStart("\")

将转换$pathpath\to\my\file

请注意,随后的前冲也将被消除,因此如果您\\\path将其减少为path