If you just want to remove the "(U) (V7.9)" Part, you also could use:
-replace("\(U\) \(V7.9\) ","")
But you have to use the escapecharacter for the parantheses too. And dont forget the following spacecharacter, because we dont want to get a doublespace.
Also theres an option to use the
substring(start,length) Method. But there you have to calculate the beginning of the "(U) (V7.9)" Part.
$string = "Randomname (U) (V7.9) (USA).txt"
$string.substring(0, $string.length - 20) + $string.substring($string.length - 9)
20 is the number of chars (beginning on back) to the first character of the string to remove (in this case:
9 is the number of chars (beginning on back) to the first character after the string to remove (in this case:
(USA), cause we dont want to get a double-space).
This method is independent of the Length of the
Randomnamebut only works with known position and length of the string to remove. Anyways the
-replace-Method is easier to use, if you know the escapechararcter. I just wanted to mention an other way to get the desired output.