regex - 正则表达式,删除最后一个正斜杠后的所有内容

标签 regex powershell

我正在尝试在 PowerShell 中使用正则表达式来删除此字符串中最后一个斜杠中的所有内容;

 NorthWind.ac.uk/Users/Current/IT/Surname, FirstName
 NorthWind.ac.uk/Users/Dormant/DifferentArea/Surname, FirstName

我需要删除姓氏、名字,包括/。
字符串应如下所示。
 NorthWind.ac.uk/Users/Current/IT

如果有人能帮助我,我将不胜感激。

我试过这个; -replace '([/])$',''但我似乎无法让它工作。

谢谢

最佳答案

替换 /[^/]*$带有空字符串

关于regex - 正则表达式,删除最后一个正斜杠后的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8590052/

相关文章:

C# 根据模式生成随机字符串

Powershell - 分批循环遍历对象 3

powershell - 如何在Powershell中使用SHGetStockIconInfo?

arrays - 将 Powershell PSCustomObject 复制到数组元素将传递引用,而不是值

regex - 正则表达式和 sed 从数百个文件中删除某些字符串的所有出现

javascript - 用等效的 HTML 替换字符串。除了 <a> 标签

regex - Scala 正则表达式模式提取器

ruby - 检查两个字符串是否匹配不区分大小写

powershell - 有关使用PowerShell Select-String,exiftool(-k)的问题

powershell - Powershell Net-Cookie到期