Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
code to grab all the strings matching a given regex and put them in a buffer, along with sample use for IPs
(defun collect-regexp-results (regex)
;;; collects all the matches of regex in a buffer called *collect-result*
;;; then switches to that buffer
;;; TODO refactor this to take the region as a parameter
(interactive "Mregex to search for: ")
(let ((curmin (region-or-buffer-beginning))
(curmax (region-or-buffer-end)))
(save-excursion
(goto-char curmin)
;; (goto-char (region-or-buffer-beginning))
(while (re-search-forward regex curmax t)
(let ((retval (match-string-no-properties 0)))
(with-current-buffer (get-buffer-create "*collect results*")
(insert retval)
(insert "\n"))))
(switch-to-buffer "*collect results*"))))
(defun collect-ip-addresses ()
(interactive)
(collect-regexp-results "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.