Emacs 26.1
In scratch buffer I has text
KRW-EOS
hel-how
hello-how-ar
h-privet
kak-del
123-567
aaa-bbb
AAA-BBB
AAAA-BBBB
AAA-BB
AA-BBB
A-A
AAAAAAAAAA BBBBBB
AAA BBB
ZZZ-YYY
M-x regexp-builder
Input next regexp:
\b[A-Z]{3}-\b[A-Z]{3}
But I get message: No matches
Why?
KRW-EOS
- is match!!!
{
and}
match themself and don't have special meaning unless you escape them i.e.\{
and\}
, (elisp) Syntax of Regexps says "The special characters are ‘.’, ‘*’, ‘+’, ‘?’, ‘[’, ‘^’, ‘$’, and ‘\’;". – xuchunyang Jan 04 '19 at 12:44re-builder
supports three different syntaxes to represent one regexp:read
,string
andrx
. Take \b for example, theread
syntax is"\\b"
(the same as the actual Emacs Lisp code andread
stands for Emacs Lisp reader); thestring
syntax is"\b"
(the same asC-M-s
, the minibuffer will escape\
for you); therx
syntax is(rx word-boundary)
(it is also actual Emacs Lisp code but usingrx
). – xuchunyang Jan 04 '19 at 16:09read
, see the variablereb-re-syntax
, so you need to escape \ by yourself. If you usestring
syntax, then that pattern will work. You can change syntax by changingreb-re-syntax
orC-c C-i
(reb-change-syntax
). – xuchunyang Jan 04 '19 at 16:13