Powershell Regular Expressions Save the DayCopy a string from between two other characters/strings (as in a UNC Path).
I had a UNC path like this:
I needed to rip out just the server part of that whole mess, which I did so with this regular expression (after fooling with it for way too long!!):
$TargetUNC = "\\server\share\folder\folder\folder\file.txt"
$ServerName = [regex]::match($TargetUNC,'[^\\]+').value
#The line above will strip out "server" from the UNC string and save it to variable $ServerName