all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Substring matched by regex
@ 2008-01-13  4:16 Aaron Maxwell
  2008-01-13  9:13 ` Nikos Apostolakis
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Maxwell @ 2008-01-13  4:16 UTC (permalink / raw)
  To: help-gnu-emacs

In a function, how do I get the value of a string matched by a regex?

In a function I'm writing, I need to parse the first bit of text matching a 
certain regex prior to point.  re-search-backward will get the start and end 
positions of that string (accessible to me via match-data), but I need a 
function that will get the actual text as a string.  Something 
like "str-from-current-buffer" in this snippet:

(defun fetch-text-to-parse ()
  (interactive)
  (save-excursion
    (progn
      (re-search-backward "regexp.to.match")
      (str-from-current-buffer (car (match-data)) (cadr (match-data))))))

copy-region-as-kill will kind of work, but it smells like a hack and (more 
importantly) pollutes the kill ring.  Could someone point me to a good way to 
do what I'm trying to do here?

Thanks much.

-- 
Aaron Maxwell
http://redsymbol.net

Business Owners and Self-Employed:  You're NOT Alone!
The Business Butler - http://businessbutler.us

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-13 17:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.6094.1200197806.18990.help-gnu-emacs@gnu.org>
2008-01-13 13:58 ` Substring matched by regex Ralf Angeli
2008-01-13  4:16 Aaron Maxwell
2008-01-13  9:13 ` Nikos Apostolakis
2008-01-13 17:24   ` Aaron Maxwell

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.