
我已經嘗試了一個小時,似乎無法獲得正確的正則表達式任何想法?
這:
src =“https://www.mywebsite.com/embedframe/84398934/need-this-text-and-the-forward-slash-before-it-removed”frameborder =“0”寬度=“600”高度=“ 400“滾動=“否”allowfullscreen=“allowfullscreen”>
對此:
src =“https://www.mywebsite.com/embedframe/84398934”frameborder =“0”寬度=“600”高度=“400”滾動=“否”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">
螢幕截圖: