Reputation: 221
My string is:
$dst = "Folder_1\SubFolder_2\3\4\5"
My goal is to have:
$dst_OK = "SubFolder_2\3\4\5"
I tried use split function like this:
$dst_OK = $dst.split("\")[0]
but the result is Folder_1 only.
Upvotes: 2
Views: 543
Reputation: 1377
You can do it with this snippet:
$first, $rest = "Folder_1\SubFolder_2\3\4\5" -split '\\'
$rest = $rest -join '\'
Upvotes: 0
Reputation: 58931
You could use the following regex to remove the left side of the string:
$dst_OK = $dst -replace '^.*?\\'
However, since it looks like you are dealing with a path, you may consider to using builtin function within the System.IO.Path
namespace.
Upvotes: 1