A regex is not needed. There's Split-Path
that parses paths and returns desired sections.
For example (this is on MacOS, should work the same on Windows)
PS >pwd
/Users/myHomeDir
PS >pwd | split-path -leaf
myHomeDir
Also, a string that contains a path can be processed. Like so,
$p = "C:Program FilesStackOverflowPowershellRegex"
split-path -leaf $p
Regex
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…