regex - 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
解决方案
在查找中使用以下正则表达式:
.+\/(.*)$
它所做的只是匹配所有内容,直到'\'
遇到 a (贪婪地),然后捕获所有内容直到行尾。
将其替换为:
$1
确保在 Notepad++ 中选择正则表达式选项。请注意,这也适用于所有文件扩展名,而不仅仅是.jpg
.
推荐阅读
- dart - Dart AOT 是如何工作的?
- kubernetes - 我可以使用从 pod 中的 init 容器创建的配置映射吗
- datastax-enterprise - 使用 DSE 高级复制与手动多 DC 设置进行灾难恢复之间的区别?
- spring - Spring Boot端口转发80到8080
- rotation - 如何围绕自身边界的中心旋转 UIBezierPath?
- r - 在 ggplot2 中绘制 shapefile:Print() 错误
- java - 异常处理,第一个 try/catch 块在接受正确输入之前不会重复
- google-cloud-stackdriver - 在 StackDriver 中跨 Google Cloud 中的多个项目设置基于日志的警报
- javascript - 与锚一起使用的滚动魔术针
- c++ - SDL2 C++ 未处理异常