I have to extract strings from paths quite often, so for example, for a zip file $x = "D:\Temp\Stuff\Zipped Things.zip"
, I can extract "Zipped Things"
by doing:
$ZipName = ((split-path $x -leaf) -split '.zip')[0]
I was wondering if there are more efficient ways to do this. Could this be possible with a single regex expression that captures whatever is bounded between the last instance of \
in the string and .zip$
? Or maybe there is an even more efficient way?