From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: double backslash problem in elisp Date: Fri, 21 Aug 2009 13:11:53 +0300 Organization: A noiseless patient Spider Message-ID: <87ljldtr12.fsf@iki.fi> References: <2cb7861e-3cf9-4613-b0a6-194ae80d0b6e@i8g2000pro.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1250851330 27297 80.91.229.12 (21 Aug 2009 10:42:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Aug 2009 10:42:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 21 12:42:03 2009 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 1MeRZJ-0005zK-NV for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Aug 2009 12:42:02 +0200 Original-Received: from localhost ([127.0.0.1]:40840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeRZI-0005h3-Jy for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Aug 2009 06:42:00 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!nx01.iad01.newshosting.com!newshosting.com!216.196.98.140.MISMATCH!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.straub-nv.de!feeder.eternal-september.org!eternal-september.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-X-Trace: news.eternal-september.org U2FsdGVkX19o4bkPUnBeMSLxdfupaclO6Qdo83qZ05eyN3s7hVP+whbbkeG+GwKbRM37FGAenjMTL4H1p/fTWUXuXxbhLTClG1JKKcU7AsV3B/TLHY5aTnkgm2604q6WFzB2vNgksfH0KX4uQcq4N5KTm7BDUh4K Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Fri, 21 Aug 2009 10:11:53 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1/w19AVa3ERCayNjWgrMObY47ARfTYyBsqcQzb/XwJ/Pg== Cancel-Lock: sha1:wHXyqRloWWBvqLvDW8jj4LSvmM4= sha1:rBot8TjoeE7x/CRn3joZqew3jJE= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:172180 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:67324 Archived-At: On 2009-08-21 02:43 (-0700), Xah Lee wrote: > this is really a strang error. > > eval this: > (replace-regexp-in-string "/" "\\" "//169.254.153.147/xah/Documents/ > alice artwork scans/") > > > i get this error: > > Debugger entered--Lisp error: (error "Invalid use of `\\' in > replacement text") > any idea why? Because backslash already has back-reference meaning in replace strings (\&, \1, \2 ...). Hence a single backslash is illegal. So, you want a single backslash literally in the replace string. First you put double backslash to escape the special meaning in Lisp strings ("\\"), then you must double it to escape the special meaning in regexp replace strings ("\\\\"). Alternatively you can give non-nil LITERAL argument for replace-regexp-in-string; this takes out the special regexp meaning. So these are the options: (replace-regexp-in-string "/" "\\\\" "string") (replace-regexp-in-string "/" "\\" "string" nil t) > basically am trying to prepare a path to feed to w32-shell-execute. Note that you may need shell-quote-argument too.