6

For example, I have the following content in the buffer:

123
1234
12345
123456
1234567

To match the 4 numbers, I need the regular expression of \d{4}. I would like to do the same in Emacs, when I press C-s and type the regexp.

When I'm looking in the documentation of Emacs regexp, many various regexp, Emacs own regexp, applications in Emacs Lisp, and so on, it's intensively documented.

I just want to have interactive search, type the regexp \d{4} and find the match. How could I apply that? The documentation gave no directly answer on this.

ReneFroger
  • 3,850
  • 23
  • 66

1 Answers1

8

As far as I can tell, there is no \d in Emacs regular expressions. So, @Tobias's comment is (mostly) correct, except that you need to escape the curly brackets. Either of the following will work:

`C-M-s` => [0-9]\{4\}
`C-M-s` => [[:digit:]]\{4\}
Dan
  • 32,980
  • 7
  • 102
  • 169