I have this code to find empty strings in a region.
(defun replace-in-region (start end)
(interactive "r")
(let ((region-text (buffer-substring start end))
(temp nil))
(delete-region start end)
(setq temp (replace-regexp-in-string "\\_>" "X" region-text))
(insert temp)))
When I use it on a region it wipes it out, no matter the content of said region, and gives the error "Args out of range: 4, 4".
When I use query-replace-regexp
in a region containing:
abcd abcd
abcd 11.11
Been the regexp \_>
(note that there is only one backslash) and rep X
the resulting region after 4 occurences are replaced is:
abcdX abcdX
abcdX 11.11X
What am I missing here?
buffer-substring
anddelete-region
has its own function:delete-and-extract-region
.