I know how to do a normal search and replace ,but say for instance that I want to replace all numbers in a buffer that starts with a 0 and the second number is a generic number, how do I match that pattern?

Say that I want to remove all numbers that begins with a zero followed by some other number.

1 Answer 1


Here is how you can remove all numbers starting with 0 using query-replace-regexp.

  1. C-M-% (default binding for query-replace-regexp)
  2. \b0[0-9]+ RET*
  3. RET
  4. Now each SPACE key hit will replace one match (Hit ! to replace all matches). Hit ? to learn about more query-replace bindings.

* Learn more about the elisp regular expressions from the Regular Expressions section in Emacs manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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