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!!!

a_subscriber
  • 3,854
  • 1
  • 17
  • 47
  • 3
    `{` and `}` match themself and don't have special meaning unless you escape them i.e. `\{` and `\}`, [(elisp) Syntax of Regexps](https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-of-Regexps.html) says "The special characters are ‘.’, ‘*’, ‘+’, ‘?’, ‘[’, ‘^’, ‘$’, and ‘\’;". – xuchunyang Jan 04 '19 at 12:44
  • @xuchunyang: Please consider posting your comment as an answer. – Drew Jan 04 '19 at 14:02
  • @xuchunyang \b[A-Z]\{3\}-\b[A-Z]\{3\} - not help. Same result. – a_subscriber Jan 04 '19 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 04 '19 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 04 '19 at 16:13
  • If re-builder shows “No matches”, then your pattern is definitively **not** a match. Claiming otherwise in your question is nonsensical -- you should be asking what is *wrong* with your regexp, rather than insisting that it is correct. – phils Jan 04 '19 at 21:15
  • Please also refer to https://emacs.stackexchange.com/q/5568 which will also help you with the different syntax options. – phils Jan 04 '19 at 21:16

0 Answers0