Get all strings matching a regexp in a given buffer (very easily with m-buffer)
I want to parse a given buffer and extract all strings that match a regexp and get a list of strings.
That would be done with a regexp search, matching groups, and extracting matches. We would
use-restriction, do a
search-forward-regexp, use backslashes to delimit groups (and even double backslashes in elisp), then get back the matches with
match-string and maybe
The following returns a list of markers:
(m-buffer-match (current-buffer) "a regexp")
If you want a list of strings, do
(m-buffer-match-string-no-properties (m-buffer-match (current-buffer) "a regexp"))
And yeah, that's it. We can also replace, delete, extract matches, apply a function to matches, add properties or overlays,…
Note that there's no documentation on github (edit: see commentary), but the sources are very well documented (looks like literate programming actually), and we generate the doc ourselves as indicated.