Emacs 7 - Regexp in Emacs
Publish date: Sep 20, 2019
The Regexp Builder
Regular expressions are very useful for text manipulation. Emacs has a useful tool called regexp-builder (try M-x regexp-builder
).
A Useful Function
We can use this regexp to replace text in a file. This is a sample functions that extracts the urls from a html file.
(defun getlinks ()
(interactive)
(beginning-of-buffer)
(keep-lines "<img")
(replace-regexp "<.*src=\"\\(http[\/\:\.\-a-z]+\\).*" "\\1")
(mark-whole-buffer)
(indent-region (point-min) (point-max)))