2017-02-20 23 views
1

考慮以下幾點:查找和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替換爲「貓*牆」「狗·橋」導致:

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 

我知道我能找到替代只是貓 - >狗和接受對方的例子,但我不知道我該怎麼做這一切自動

+0

使用'M-X更換-regexp' – Barmar

+0

使用捕獲組獲得cat'和'wall'之間'的一部分,所以你可以把它複製到更換。 – Barmar

+0

這不是一個真正的編程問題。最好在Emacs.SE或SuperUser.com上提問。 – Barmar

回答

1

感謝@Barmar

我一直在尋找的正則表達式是

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