[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Substring matched by regex

From: Aaron Maxwell
Subject: Substring matched by regex
Date: Sat, 12 Jan 2008 20:16:25 -0800
User-agent: KMail/1.9.6 (enterprise 0.20070907.709405)

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 ()
      (re-search-backward "")
      (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

Business Owners and Self-Employed:  You're NOT Alone!
The Business Butler -

reply via email to

[Prev in Thread] Current Thread [Next in Thread]