emacs regexps中的OR运算符是什么? [英] What is the OR operator in emacs regexps?

查看:142
本文介绍了emacs regexps中的OR运算符是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

手册说使用'\ |',如a\ | b匹配a或b。但是当我使用正则表达式构建器或对齐正则表达式与True\ | False,它不会识别True或False。我收到以下消息:

 错误的参数类型:integer-or-marker-p,nil 
解决方案

使用双重转义: \\ |



几个附加注释: strong>



Emacs有两个转义样式,一个在EmacsLisp中,另一个在命令中使用时,
ie。从 Mx 提示( rgrep 发生,...)


在EmacsLisp中,使用双反斜杠 \\ |


...


Mx ... 使用单个反斜杠 \ |


...作为旁注,当编写嵌入式EmacsLisp时,例如在yasnippet动态扩展中,必须使用四元反斜杠: \\\\\ | (以避免双反斜杠。)



总是避免这种情况(如果可能的话),例如在yasnippet中,您可以提供模式相关的emacslisp,而不需要额外的转义,通过 .yas-setup.el


The manual says to use '\|', as in a\|b matches a or b. But when I use it with regexp builder or align-regexp e.g. with, "True\|False", it doesn't recognize "True" or "False". I get the following message:

Wrong argument type: integer-or-marker-p, nil

What am I doing wrong?

解决方案

Use double escape: \\|

A Few Additional Notes:

Emacs has 2 escaping styles, one in EmacsLisp the other when used in commands,
ie. from the M-x prompt (rgrep, occur, …)

In EmacsLisp, use the double backslash \\|

From M-x … use a single backslash \|

… As a side note, when writing embedded EmacsLisp, for example in yasnippet dynamic expansions, you have to use a quadruple backslash: \\\\| (to escape the double backslashes.)

Always avoid this (if possible), for example in yasnippet you can provide mode related emacslisp, without the additional escaping, via a .yas-setup.el

这篇关于emacs regexps中的OR运算符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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