From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Aaron Maxwell Newsgroups: gmane.emacs.help Subject: Substring matched by regex Date: Sat, 12 Jan 2008 20:16:25 -0800 Message-ID: <200801122016.25693.amax@redsymbol.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1200197851 12234 80.91.229.12 (13 Jan 2008 04:17:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Jan 2008 04:17:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 13 05:17:52 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JDuI5-0001cc-LB for geh-help-gnu-emacs@m.gmane.org; Sun, 13 Jan 2008 05:17:45 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JDuHh-0007IE-C2 for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Jan 2008 23:17:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JDuH7-00074J-1b for help-gnu-emacs@gnu.org; Sat, 12 Jan 2008 23:16:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JDuH5-00072i-Du for help-gnu-emacs@gnu.org; Sat, 12 Jan 2008 23:16:44 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JDuH4-00072U-Tc for help-gnu-emacs@gnu.org; Sat, 12 Jan 2008 23:16:42 -0500 Original-Received: from smtp-gw31.mailanyone.net ([208.70.128.57]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JDuH5-00088K-Ai for help-gnu-emacs@gnu.org; Sat, 12 Jan 2008 23:16:43 -0500 Original-Received: from mailanyone.net by smtp-gw31.mailanyone.net with esmtpsa (TLSv1:AES256-SHA:256) (MailAnyone extSMTP redsymbol) id 1JDuGy-0003k9-Uy for help-gnu-emacs@gnu.org; Sat, 12 Jan 2008 22:16:40 -0600 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:50691 Archived-At: 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