想要删除第n个"/"之后的所有内容从记事本++或Excel中的超链接 [英] Want to remove everything after nth "/" from hyperlink in Notepad++ or Excel

查看:102
本文介绍了想要删除第n个"/"之后的所有内容从记事本++或Excel中的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助:寻找一种方法来删除超链接中"/"的第n次出现(最可能是第4或第5)之后的所有内容.例如,如果我有

I need some help: looking for a way to remove everything after the nth occurrence (most likely 4th or 5th) of "/" in a hyperlink. For instance, if I have

https://www.forbes.com/forbes/welcome/?toURL=https://forbes.com/&refURL=&referrer=

我想要的输出是:

https://www.forbes.com/forbes/welcome/

此外,如果链接仅包含< 4"/",我想保留所有内容.在此先感谢!

Additionally, if a link only has <4 "/", I'd like to keep everything. Thanks in advance!!

推荐答案

使用记事本++:

  • Ctrl + H
  • 查找内容:^((?:[^/]*/){5}).*$
  • 替换为:$1
  • 检查环绕
  • 检查正则表达式
  • 请勿检查. matches newline
  • 全部替换
  • Ctrl+H
  • Find what: ^((?:[^/]*/){5}).*$
  • Replace with: $1
  • check Wrap around
  • check Regular expression
  • DO NOT CHECK . matches newline
  • Replace all

说明:

^               : begining of lin
  (             : start group 1
    (?:         : start non capture group
      [^/]*     : 0 or more any character that is not a slash
      /         : a slash
    ){5}        : group must appear 5 times
  )             : end group 1
  .*            : 0 or more any character
$               : end of line

替换:

$1          : content of group 1 (ie. everything before the 5th slash)

给定示例的结果:

https://www.forbes.com/forbes/welcome/

这篇关于想要删除第n个"/"之后的所有内容从记事本++或Excel中的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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