suppose i want write a command that do a find/replace on a region
which is more efficient?
(defun space2underscore-region (p1 p2)
"Replace space by underscore in region."
(narrow-to-region p1 p2)
(while (search-forward " " nil t) (replace-match "_")) ) )
(setq meat (replace-regexp-in-string " " "_"
(buffer-substring-no-properties p1 p2)) )
(delete-region p1 p2)
(replace-string " " "_" nil p1 p2)
it appears to me, the first is most efficient but is most cumbersome.
The last is most lean, but least efficient.
Xah ∑ xahlee.org ☄