0

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

enter image description here

Why?

KRW-EOS - is match!!!

  • 3
    { 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 4 at 12:44
  • @xuchunyang: Please consider posting your comment as an answer. – Drew Jan 4 at 14:02
  • @xuchunyang \b[A-Z]\{3\}-\b[A-Z]\{3\} - not help. Same result. – a_subscriber Jan 4 at 15:21
  • 1
    @Alexei re-builder supports three different syntaxes to represent one regexp: read, string and rx. Take \b for example, the read syntax is "\\b" (the same as the actual Emacs Lisp code and read stands for Emacs Lisp reader); the string syntax is "\b" (the same as C-M-s, the minibuffer will escape ` for you); the rx` syntax is (rx word-boundary) (it is also actual Emacs Lisp code but using rx). – xuchunyang Jan 4 at 16:09
  • @Alexei and the default syntax is read, see the variable reb-re-syntax, so you need to escape \ by yourself. If you use string syntax, then that pattern will work. You can change syntax by changing reb-re-syntax or C-c C-i (reb-change-syntax). – xuchunyang Jan 4 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.