I have the following contexts:

4. Pattern-Matching Conditional: How to use pcase and friends.
5. Iteration: while loops.
6. Generators: Generic sequences and coroutines.

and intent add ** to the head of each lines thus try replace-regexp
^\([::digit::]\) → ** \1
However, nothing happened.

What's the problem with my solution?


The character class name should be enclosed between [: and :](see emacs manual), the correct pattern is


Since you have a single group you can skip the parentheses and refer to the whole match with \&, e.g:

^[[:digit:]] → ** \&
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.