首页 > 解决方案 > Search and replace with Notepad++ keeping after defined string

问题描述

I have a file with content:

http://domain1.tld/random1/random11/random111/file1.jpg
http://domain2.tld/random12/file2.jpg
http://domain3.tld/file3.jpg
http://sub1.domain4.tld/blah/blahblah/file4.jpg

I want to search and replace to:

file1.jpg
file2.jpg
file3.jpg
file4.jpg

标签: regexreplacenotepad++

解决方案


在查找中使用以下正则表达式:

.+\/(.*)$

它所做的只是匹配所有内容,直到'\'遇到 a (贪婪地),然后捕获所有内容直到行尾。

将其替换为:

$1

演示

确保在 Notepad++ 中选择正则表达式选项。请注意,这也适用于所有文件扩展名,而不仅仅是.jpg.


推荐阅读