On the Code Golf Stack Exchange site today, I found this answer in Clojure to the question "Get all links on a webpage".
(->> (slurp "http://www.stroustrup.com")
(re-seq #"(?:http://)?www(?:[./#\+-]\w*)+"))
Without the fancy macro, it's just this:
(re-seq #"(?:http://)?www(?:[./#\+-]\w*)+" (slurp "http://www.stroustrup.com"))
This returns the list:
("http://www.morganstanley.com/" "http://www.cs.columbia.edu/" "http://www.cse.tamu.edu" ...)
Can I do something similar in Emacs Lisp?
Perhaps a function like (re-seq regexp (buffer-string))
that returns '(firstmatch secondmatch thirdmatch ...)
?
M-x occur
does, but I'd look inside for more low-level functions to do that.occur
. I'll have to look through its source.s.el
, but maybe there's more out there. Here: github.com/magnars/s.el#s-match-strings-all-regex-string how about this?