all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Converting a non-escaped regexp to an escaped version
@ 2007-06-07 12:32 HippoMan
  2007-06-07 14:14 ` Nikolaj Schumacher
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: HippoMan @ 2007-06-07 12:32 UTC (permalink / raw)
  To: help-gnu-emacs

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
`match-string'.

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:

     \bfoo\b.*:.*\bbar\([0-9]\{9\}quack\.quack\)\b

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:

     \\bfoo\\b.*:.*\\bbar\\([0-9]\\{9\\}quack\\.quack\\)\\b

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.

--
 hippoman@gmail.com

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Converting a non-escaped regexp to an escaped version
@ 2007-06-07 21:25 martin rudalics
  0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2007-06-07 21:25 UTC (permalink / raw)
  To: hippoman; +Cc: help-gnu-emacs

You could also have a look at a thing I wrote

http://lists.gnu.org/archive/html/gnu-emacs-sources/2005-11/msg00004.html

It has two commands which permit to find the next and previous match
for the regexp you are about to write in the same Elisp buffer.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-06-11  9:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-07 12:32 Converting a non-escaped regexp to an escaped version HippoMan
2007-06-07 14:14 ` Nikolaj Schumacher
2007-06-07 14:21 ` Juanma Barranquero
     [not found] ` <mailman.1734.1181225695.32220.help-gnu-emacs@gnu.org>
2007-06-07 14:35   ` Joost Kremers
2007-06-07 15:12     ` HippoMan
2007-06-07 15:19       ` Joost Kremers
2007-06-11  9:31 ` Johan Bockgård
  -- strict thread matches above, loose matches on Subject: below --
2007-06-07 21:25 martin rudalics

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.