Notepad ++如何从url中删除文本

Notepad ++如何从url中删除文本

我已经尝试了一个小时,但似乎无法得到正确的正则表达式,有什么想法吗?

这:

src="https://www.mywebsite.com/embedframe/84398934/need-this-text-and-the-forward-slash-before-it-removed" frameborder="0" width="600" height="400" scrolling="no" allowfullscreen="allowfullscreen">

对此:

src="https://www.mywebsite.com/embedframe/84398934" frameborder="0" width="600" height="400" scrolling="no" allowfullscreen="allowfullscreen">

答案1

使用 Notepad++(记事本不支持正则表达式):

  • Ctrl+H
  • 找什么:src="https://.*\K/[^/"]+(?=")
  • 用。。。来代替:LEAVE EMPTY
  • 检查环绕
  • 检查正则表达式
  • Replace all

解释:

src="https://   # literally
.*              # 0 or more any character
\K              # forget all we have seen until this position
/               # a slash
[^/"]+          # 1 or more any character that is not slash or double quote
(?=")           # positive lookahead, make sure we have a double quote after

给定示例的结果:

src="https://www.mywebsite.com/embedframe/84398934" frameborder="0" width="600" height="400" scrolling="no" allowfullscreen="allowfullscreen">

屏幕截图:

在此处输入图片描述

相关内容