Skip to main content
Added usage example.
Source Link

Here is how you can do it based on strings, as requested.

(defun re-seq (regexp string) "Get a list of all regexp matches in a string" (save-match-data (let ((pos 0)   matches) (while (string-match regexp string pos) (push (match-string 0 string) matches) (setq pos (match-end 0))) matches))) ; Sample URL (setq urlreg "\\(?:http://\\)?www\\(?:[./#\+-]\\w*\\)+") ; Sample invocation (re-seq urlreg (buffer-string)) 

Here is how you can do it based on strings, as requested.

(defun re-seq (regexp string) "Get a list of all regexp matches in a string" (save-match-data (let ((pos 0) matches) (while (string-match regexp string pos) (push (match-string 0 string) matches) (setq pos (match-end 0))) matches))) (setq urlreg "\\(?:http://\\)?www\\(?:[./#\+-]\\w*\\)+") 

Here is how you can do it based on strings, as requested.

(defun re-seq (regexp string) "Get a list of all regexp matches in a string" (save-match-data (let ((pos 0)   matches) (while (string-match regexp string pos) (push (match-string 0 string) matches) (setq pos (match-end 0))) matches))) ; Sample URL (setq urlreg "\\(?:http://\\)?www\\(?:[./#\+-]\\w*\\)+") ; Sample invocation (re-seq urlreg (buffer-string)) 
Source Link

Here is how you can do it based on strings, as requested.

(defun re-seq (regexp string) "Get a list of all regexp matches in a string" (save-match-data (let ((pos 0) matches) (while (string-match regexp string pos) (push (match-string 0 string) matches) (setq pos (match-end 0))) matches))) (setq urlreg "\\(?:http://\\)?www\\(?:[./#\+-]\\w*\\)+")