From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: HippoMan Newsgroups: gmane.emacs.help Subject: Converting a non-escaped regexp to an escaped version Date: Thu, 07 Jun 2007 12:32:53 -0000 Organization: http://groups.google.com Message-ID: <1181219573.415318.285860@n4g2000hsb.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1181224896 14401 80.91.229.12 (7 Jun 2007 14:01:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 7 Jun 2007 14:01:36 +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 Jun 07 16:01:35 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HwIYO-0006wI-4c for geh-help-gnu-emacs@m.gmane.org; Thu, 07 Jun 2007 16:01:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HwIYN-0006K8-LQ for geh-help-gnu-emacs@m.gmane.org; Thu, 07 Jun 2007 10:01:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!n4g2000hsb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-NNTP-Posting-Host: 167.203.158.141 Original-X-Trace: posting.google.com 1181219573 15023 127.0.0.1 (7 Jun 2007 12:32:53 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 7 Jun 2007 12:32:53 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 nykchlnc03 (NetCache NetApp/6.0.3D2), Version 2.2-Build_Linux_1063 $Date: 11/16/2005 13:40:0013$(IWSS), 1.1 nykchlnc03 (NetCache NetApp/6.0.3D2), 1.1 nykprtnc02 (NetCache NetApp/6.0.3D2) Complaints-To: groups-abuse@google.com Injection-Info: n4g2000hsb.googlegroups.com; posting-host=167.203.158.141; posting-account=LFgiJw0AAAA9JjgEI-Yqa3QO3e_RXOXE Original-Xref: shelby.stanford.edu gnu.emacs.help:149161 X-Mailman-Approved-At: Thu, 07 Jun 2007 10:01:08 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:44748 Archived-At: 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