简体   繁体   English

在emacs中搜索并替换字符序列

[英]Search and replace a sequence of characters in emacs

I am using Emacs, and I have a file with some strings like this.. 我正在使用Emacs,并且我有一个包含这样的字符串的文件..

IMPORTED_DATA_K_NAME
IMPORTED_DATA_L_PHONE
IMPORTED_DATA_M_URL

I want to change the contents to .. 我想将内容更改为..

IMPORTED_DATA_A_NAME
IMPORTED_DATA_B_PHONE
IMPORTED_DATA_C_URL

Basically change _K_ to _A_ and _L_ to _B_ and so on.. 基本上将_K_ to _A_更改为_K_ to _A__K_ to _A_更改_K_ to _A_ _L_ to _B_ ,依此类推。

This is a rather large file with lot of repetitions. 这是一个很大的文件,有很多重复。 I was looking at query-replace-regex but was not sure if that accomplishes this or is there a better way to accomplish this change. 我正在查看query-replace-regex,但不确定是否能完成此操作,或者是否有更好的方法来完成此更改。

Any help is appreciated. 任何帮助表示赞赏。

CM-% or Mx query-replace-regexp with the regexp _\\([KZ]\\)_ and the replacement _\\,(char-to-string (- (string-to-char \\1) 10))_ . CM-%Mx query-replace-regexp使用正则表达式_\\([KZ]\\)_和替换_\\,(char-to-string (- (string-to-char \\1) 10))_ \\,(expr) in the replacement evaluates (expr) as lisp. 替换中的\\,(expr)评估为(expr)为Lisp。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM