Regular Expression, remove everything after last forward slash

后端 未结 5 771
逝去的感伤
逝去的感伤 2020-12-14 21:07

I\'m trying to use a regular expression within PowerShell to remove everything from the last slash in this string;

 NorthWind.ac.uk/Users/Current/IT/Surname,         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 21:55

    Here's a solution that doesn't require regular expressions:

    PS> $cn = 'NorthWind.ac.uk/Users/Current/IT/Surname, FirstName' -split '/'
    PS> $cn[0..($cn.count-2)] -join '/'
    NorthWind.ac.uk/Users/Current/IT
    

提交回复
热议问题