[Top][All Lists]

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

Converting a non-escaped regexp to an escaped version

From: HippoMan
Subject: Converting a non-escaped regexp to an escaped version
Date: Thu, 07 Jun 2007 12:32:53 -0000
User-agent: G2/1.0

During development of elisp code that I'm writing, I test regular
expressions via the interactive use of M-x re-search-forward.  Once
I've come up with a regexp that works, I often will want
to yank it into my elisp code, for example, into a call to

Of course, once I do this, I then have to go through the regexp and
double all of the backslashes within it.  In order to make this easier
for myself, I'd like to have an elisp function that will yank a
string while auto-doubling every backslash it contains.  I'm happy to
write such a function, but before I re-invent the wheel, I'm
wondering if such a thing has already been invented.

In case this isn't clear, here's what I want to do:

1. Test a regular expression interactively, for example, via
   the use of M-x re-search-forward.

2. Assume that I finally decide that the following regexp is
   the one that I want to use within my elisp code:


3. Put this regexp to the kill ring.

4. Use my proposed function to yank it into my elisp code
   (for example, within an invocation of `match-string'), as follows:


Note that I'm not asking any of you to write this function for
me, as I can do this.  I just want to know whether something
like this already exists within the emacs code base or perhaps
somewhere else on the net.

Thanks in advance.


reply via email to

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