查找并替换emacs中的周围单词

时间:2017-02-20 22:50:56

标签: regex emacs

请考虑以下事项:

The cat jumped over the wall
The cat sat on the wall
The cat strolled along the wall
The cat hid under the hedge
The horse considered the wall

我想在emacs中用“dog * bridge”替换“cat * wall”,结果是:

The dog jumped over the bridge
The dog sat on the bridge
The dog strolled along the bridge
The cat hid under the hedge
The horse considered the wall

我知道我可以找到替换只是猫 - >狗并接受每个例子,但我想知道如何自动完成所有这些

1 个答案:

答案 0 :(得分:1)

谢谢@Barmar

我正在寻找的正则表达式是

cat \(.*\) wall -> dog \1 bridge