all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: HippoMan <hippoman@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Converting a non-escaped regexp to an escaped version
Date: Thu, 07 Jun 2007 12:32:53 -0000	[thread overview]
Message-ID: <1181219573.415318.285860@n4g2000hsb.googlegroups.com> (raw)

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

             reply	other threads:[~2007-06-07 12:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-07 12:32 HippoMan [this message]
2007-06-07 14:14 ` Converting a non-escaped regexp to an escaped version 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1181219573.415318.285860@n4g2000hsb.googlegroups.com \
    --to=hippoman@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.