正则表达式,删除最后一个正斜杠后的所有内容 [英] Regular Expression, remove everything after last forward slash

查看:56
本文介绍了正则表达式,删除最后一个正斜杠后的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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, FirstName
 NorthWind.ac.uk/Users/Dormant/DifferentArea/Surname, FirstName

我需要删除姓氏、名字,包括/.该字符串应如下所示.

I need to remove Surname, FirstName including the /. The string should look like this.

 NorthWind.ac.uk/Users/Current/IT

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

If someone could help me, I would be very grateful.

我已经试过了;-replace '([/])$','' 但我似乎无法让它工作.

I have tried this; -replace '([/])$','' but I can't seem to get it to work.

谢谢

推荐答案

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

这篇关于正则表达式,删除最后一个正斜杠后的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆