[英]What is the OR operator in emacs regexps?
The manual says to use '\\|', as in a\\|b matches a or b. 手册说要使用'\\ |',因为在\\ | b中匹配a或b。 But when I use it with regexp builder or align-regexp eg with, "True\\|False", it doesn't recognize "True" or "False".
但是当我使用regexp builder或align-regexp例如“True \\ | False”时,它不会识别“True”或“False”。 I get the following message:
我收到以下消息:
Wrong argument type: integer-or-marker-p, nil
What am I doing wrong? 我究竟做错了什么?
\\\\|
\\\\|
A Few Additional Notes: 一些附加说明:
Emacs has 2 escaping styles, one in EmacsLisp the other when used in commands, Emacs有2个转义样式,一个在EmacsLisp中,另一个在命令中使用时,
ie. 即。 from the
Mx
prompt ( rgrep
, occur
, …) 从
Mx
提示符( rgrep
, occur
,...)
In EmacsLisp, use the double backslash
\\\\|
在EmacsLisp中,使用双反斜杠
\\\\|
… ...
From
Mx …
use a single backslash\\|
从
Mx …
使用单个反斜杠\\|
… As a side note, when writing embedded EmacsLisp, for example in yasnippet dynamic expansions, you have to use a quadruple backslash: \\\\\\\\|
...作为旁注,在编写嵌入式EmacsLisp时,例如在yasnippet动态扩展中,您必须使用四重反斜杠:
\\\\\\\\|
(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
总是避免这种情况(如果可能的话),例如在yasnippet中,您可以通过
.yas-setup.el
提供与模式相关的emacslisp,而无需额外的转义。
For further details, see the discussion of '\\'
and strings in the elisp manual section 34.3.1.1 "Special Characters in Regular Expressions" 有关详细信息,请参阅elisp手册第34.3.1.1节“正则表达式中的特殊字符”中对
'\\'
和字符串的讨论
M-: (info "(elisp) Regexp Special")
RET M- :(
(info "(elisp) Regexp Special")
RET
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.