0

I want to replace a list in the form of

1)
2)
3)
4)

with

* 
*
* 

I've tried using the regex [0-9]*\), but it gives Invalid regexp: "Unmatched ) or \\)" and [0-9]*\\) replaces 0 matches. in regex-builder, [0-9]*\) matches the expected items.

I'm using spacemacs 0.300.0 on emacs 26.3

0

On writing this question, I found the (very simple) answer, so I'll put it out there for anyone else who finds this confusing (considering I found no similar questions).

It seems that the default behaviour for replace-regexp is matching parenthesis literally, so the solution was just [0-9]*) and for the usual group capturing is instead \(group\), maybe some configuration or variable changes this.

TL;DR: use ) with replace-regexp for literal matches

1
  • 1
    I imagine you want [0-9]+, not [0-9]*.
    – Drew
    Jul 2 at 19:15

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.