help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Easy regexp issue


From: Kevin Rodgers
Subject: Re: Easy regexp issue
Date: Fri, 19 Jan 2007 23:09:42 -0700
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

Barry Margolin wrote:
In article <mailman.3295.1169191738.2155.help-gnu-emacs@gnu.org>,
 Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote:
See the LITERAL argument in the doc string for replace-regexp-in-string:

(replace-regexp-in-string "/" "\\" "c:/emacs/lisp/" nil t)

Or

(replace-regexp-in-string "/" "\\\\" "c:/emacs/lisp/")

This is necessary because backslash is an escape character at two levels: Lisp strings and regexp replacement strings (e.g. the sequence \1 in the replacement represents a group matched in the regexp). So the replacement string needs to be \\, and you need to escape each \ in the string.

That was my point: If you don't need the backslash to be interpreted in
the replacement string as a submatch reference, specify a non-nil
LITERAL argument -- which should execute faster to boot.  Of course,
there's no way around the need to escape the backslash in the Lisp
string.

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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