gpt4 book ai didi

string - 如何删除此字符串的左侧?

转载 作者:行者123 更新时间:2023-12-02 23:56:31 24 4
gpt4 key购买 nike

我的字符串是:

$dst = "Folder_1\SubFolder_2\3\4\5"

我的目标是:
$dst_OK = "SubFolder_2\3\4\5"

我试过像这样使用split函数:
$dst_OK = $dst.split("\")[0]  

但结果仅是Folder_1。

最佳答案

您可以使用以下正则表达式删除字符串的左侧:

$dst_OK = $dst -replace '^.*?\\'

但是,由于看起来您正在处理路径,因此您可以考虑在 System.IO.Path命名空间中使用内置函数。

关于string - 如何删除此字符串的左侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44236568/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com