PowerShell isolating parts of strings

I have no experience with regular expressions and would love some help and suggestions on a possible solution to deleting parts of file names contained in a csv file.


A list of exported file names contains a random unique identifier that I need isolated. The unique identifier has no predictable pattern, however the aspects which need removing do. Each file name ends with one of the following variations:

V, -V, or %20V followed by a random number sequence with possible spaces, additional "-","" and ending with .PDF


GTD-LVOE-43-0021 V10 0.PDF GTD-LVOE-43-0021-V34-2.PDF GTD-LVOE-43-0021_V02_9.PDF GTD-LVOE-43-0021 V49.9.PDF


My plan was to write a script to select of the first occurrence of a V from the end of the string and then delete it and everything to the right of it. Then the file names can be cleaned up by deleting any "-" or "_" and white space that occurs at the end of a string.


How can I do this with a regular expression and is my line of thinking even close to the right approach to solving this?


REGEX: [\s\-_]V.*?\.PDF

Might do the trick. You'd still need to replace away any leading - and _, but it should get you down the path, hopefully.

This would read as follows..

start with a whitespace, - OR _ followed by a V. Then take everything until you get to the first .PDF

Need Your Help

Programming dynamic panels in VB.NET

vb.net winforms user-controls

My programming experience is short and I have written several applications but am very much still a novice in VB.NET.

Android Native Datepicker crashes in Samsung S4 device

android cordova phonegap-plugins phonegap-build android-datepicker

I have created an application in phonegap. In all the device the DatePicker(Phonegap Datepicker plugin) is working fine, except Samsung S4 device.