0

How can I split the string "FOLDER03631140M/1/7010-win10-A01-GR1XM.CAB" cleanly at the second "/" or discard the front part of the string? Theoretically, this is halfway clear to me, but desperately easy to do... Unfortunately, I still lack the routine...

Result should be that only "7010-win10-A01-GR1XM.CAB" remains from the string.

I am happy about your support

Greetings Nils

  • Does this answer your question? [Substring to Get Text after Second Period in Powershell](https://stackoverflow.com/questions/27513886/substring-to-get-text-after-second-period-in-powershell) – Ocaso Protal Mar 20 '20 at 09:40
  • 2
    `("FOLDER03631140M/1/7010-win10-A01-GR1XM.CAB" -split '/')[-1]` --> `7010-win10-A01-GR1XM.CAB` – Theo Mar 20 '20 at 09:44
  • Does this answer your question? [Split a Path and take out only the last part (filename) Powershell](https://stackoverflow.com/questions/54305545/split-a-path-and-take-out-only-the-last-part-filename-powershell): `Split-Path -Leaf FOLDER03631140M/1/7010-win10-A01-GR1XM.CAB` – iRon Mar 20 '20 at 12:20

1 Answers1

2

Try this:

$string = "The string"
$string.split("/")[2]

Here .split returns an array and we have now 3 elements. Now we can get that part in the 2nd element.

Wasif
  • 14,755
  • 3
  • 14
  • 34