Emacs:"replace-regex" 可以将所有 \command{foo} 替换为 foo 吗?



我正在编辑一个有许多这样的内容的乳胶文件:

command{a}
command{b}
...

我的问题是如何将它们更改为

a
b
... 

简单,执行M-x replace-regexp,然后键入^.*{(.*)}.*$,命中ENTER,键入1,然后再击中Enter一次。您可以微调正则态度少贪婪,或者如果需要的话,则更具体。

这是一个通用解决方案,也适用于

multiple commands on the same line: com{a} com{b}
command com{a} goes in the arbitrary place in the line

查找:\[^{]+{([^}]*)},替换为1

最新更新