From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glen Stark Newsgroups: gmane.emacs.help Subject: Elisp: get word(s) from an re-match Date: Thu, 26 Mar 2015 13:20:57 GMT Organization: Easynews - www.easynews.com Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1427376352 25305 80.91.229.3 (26 Mar 2015 13:25:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Mar 2015 13:25:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 26 14:25:51 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yb7mr-000589-DT for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Mar 2015 14:25:29 +0100 Original-Received: from localhost ([::1]:44526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb7mq-0002gw-CA for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Mar 2015 09:25:28 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!news.roellig-ltd.de!open-news-network.org!cyclone03.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!peer03.am1!peering.am1!npeersf04.am4!fx37.am4.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Original-Lines: 24 Original-X-Complaints-To: abuse@easynews.com X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. X-Received-Body-CRC: 1130045813 X-Received-Bytes: 1685 Original-Xref: usenet.stanford.edu gnu.emacs.help:211081 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:103360 Archived-At: Hi everyone, I guess this is pretty trivial, but I'm struggling a little. Consider the following: for ( Foo::iterator itr = foo.begin() ; itr != foo.end(); ++foo) I want to to a regex search within elisp for this pattern, and extract into variables "foo" and "itr". The goal is to write a refactoring script that takes old iterator loops and replaces them with for (auto x : foo), so I'd like to have the name of itr and the object being iterated over. I'm competent enough with regex's to write the regex, and replace with \1 and \2, which would get me through the auto statement, but I want to store the name of itr in a variable, so I can replace occurences of itr in the body of the code with the new auto variable. Can somone point me in the right direction? A simple example that extracts a string out of a regex match and returns it into a variable would be fantastic. Many thanks, Glen