emacs regexp-builder在replace-regexp中不起作用 [英] emacs regexp-builder doesn't work in replace-regexp

查看:155
本文介绍了emacs regexp-builder在replace-regexp中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含文本的emacs缓冲区

  a1b2c3 

使用regexp-builder,我创建正则表达式

  b \\(2\\)

可以看到匹配突出显示(b2但是,当我将表达式粘贴到 replace-regexp 中时,我得到0个比赛。无论是否有引号。获得比赛我需要使用

  b\(2\)

我想有一些逃脱在这里,但肯定我会做错事。不得不手工逃跑似乎打败了一半。

解决方案

regexp-builder 可以在几种语法中显示正则表达式。默认情况下,它使用适合放入Emacs Lisp源的语法( read 语法),因此正则表达式置于双引号之间,每个反斜杠加倍。对于交互式使用,请选择字符串语法与 Cc Ci reb-change-syntax )。


I have an emacs buffer containing the text

a1b2c3

using the regexp-builder, i create the regexp

"b\\(2\\)"

and can see the match highlighting (b2, with the 2 in a different colour).

however, when i paste the expression into replace-regexp, i get 0 matches. both with and without the quotes. to get a match i need to use

b\(2\)

i guess there's some escaping going on here, but surely i must be doing something wrong. having to manually escape seems to defeat half the point.

解决方案

regexp-builder can show the regexp in several syntaxes. By default, it uses the syntax that is appropriate to put in an Emacs Lisp source (read syntax), so the regexp is placed between double quotes and every backslash is doubled. For interactive use, select the string syntax with C-c C-i (reb-change-syntax).

这篇关于emacs regexp-builder在replace-regexp中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆