regex - emacs replace-regexp 的语法

标签 regex emacs

我试图找到每个日期并在它周围加上引号。我认为这应该是:
M-x replace-regexp 201\d-\d\d-\d\d <ret> '\&'
我也试过 [0-9]而不是 \d .

它不起作用。但是使用 isearch-forward-regexp我可以输入 [0-9][0-9]并观看目标突出显示。我在替换时做错了什么?

最佳答案

Emacs 正则表达式没有常见的 \d [0-9] 的简写.

我只是将文本 2011-04-01 放入一个新的缓冲区,回到缓冲区的开头,然后输入 M-x replace-regexp返回 201[0-9]-[0-9][0-9]-[0-9][0-9]返回 '\&' RET,并且日期用单引号括起来,正如预期的那样。

关于regex - emacs replace-regexp 的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5557106/

相关文章:

java - groovy 或 java : how to retrieve a block of comments using regex from/** ***/?

Java 正则表达式

emacs - 如何改进 emacs 的 vc-mode 注释?

emacs - SLIME 未从 Emacs 加载

c++ - 相当于 Windows 上的 random(3)?

Emacs 缓冲区内的 OpenGL 上下文

Emacs 的 PHP 模式

regex - (a+b)* 和 (a*b*)* 有什么区别?

regex - 如果在语句中找到单个单词,perl 正则表达式用于打印整个语句

regex - 删除两个特殊字符之间的字符