【发布时间】:2012-08-08 22:36:22
【问题描述】:
我在 Emacs 中尝试了 replace-regexp 命令,但我不知道如何构造正确的正则表达式。我的文件如下所示:
<img src="http://s.perros.com/content/perros_com/imagenes/thumbs/1lundehund2.jpg" />
<img src="http://s.perros.com/content/perros_com/imagenes/thumbs/1pleon2.jpg" />
我想替换为:
<img src="" class="class-1lundehund2.jpg" />
<img src="" class="class-1pleon2.jpg" />
我使用这个正则表达式没有成功(替换了 0 次):
M-x replace-regexp
Replace regexp: src\=\"http\:\/\/s\.perros\.com\/content\/perros_com\/imagenes\/thumbs\/\([a-zA-Z0-9._-]+\)\"
Replace regexp with: src\=\"\" class\=\"class-\1\"
但在 re-builder 模式下使用相同的正则表达式(更改 \([a-zA-Z0-9.-]+\) by \\([a-zA-Z0-9.-]+\\)) 所有结果都正确突出显示。我不知道发生了什么,有什么提示吗?
【问题讨论】: