[Top][All Lists]

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

Elisp: get word(s) from an re-match

From: Glen Stark
Subject: Elisp: get word(s) from an re-match
Date: Thu, 26 Mar 2015 13:20:57 GMT
User-agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://

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,


reply via email to

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