How to remove regular expression matching text in emacs?

How to remove text matching regular expression in emacs?

I believe using:

'(query-replace-regexp PATTERN EMPTY)

and

'(replace-regexp PATTERN EMPTY)

but they throw:

perform-replace: Invalid regexp: "Premature end of regular expression".

+5
source share
1 answer

In general, you can delete text that matches a given regular expression using an empty string ""as a replacement in the two functions you specify. However, as mentioned in the comments above, your regex is wrong.

For example, if your buffer contains the following text:

1. My todo list
1.1. Brush teeth
1.2. Floss
2. My favorite movies
2.1. Star Wars episodes 4-6

, , M-C-% ( , : ALT, CTRL, Shift, 5) query-replace-regexp. , . , regexp:

\([0-9]\.\)+\s-

ENTER , . , - : , .

query-replace-regexp , , . "" - query-replace-regexp, , , . , , !, Emacs , .

M-x replace-regexp M-C-%, Emacs , .

, , , delete-matching-lines , - delete-non-matching-lines.

+12

All Articles