Created
November 22, 2010 18:06
-
-
Save MrGung/710353 to your computer and use it in GitHub Desktop.
extract-regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun extract-regex (regexp) | |
"Extracts all occurrences of regexp from the current buffer." | |
(interactive "sRegexp for extraction: ") | |
(setq result '()) | |
(save-excursion | |
(beginning-of-buffer) | |
(while (re-search-forward regexp nil t) | |
(when (match-string 0) ; Got a match | |
(setq result (cons (match-string 0) result))))) | |
(let ((result-string (mapconcat 'identity result "\n"))) | |
(message result-string) | |
result-string)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment