From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier " Newsgroups: gmane.emacs.help Subject: Re: I can't believe: replace regexp in a string Date: 14 Feb 2003 10:55:08 -0500 Organization: Yale University Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <5lheb6zwkj.fsf@rum.cs.yale.edu> References: <62ede926.0302140037.4db6c80a@posting.google.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1045239550 17607 80.91.224.249 (14 Feb 2003 16:19:10 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 14 Feb 2003 16:19:10 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18jiPc-0003wH-00 for ; Fri, 14 Feb 2003 17:10:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18jiQR-0002tm-08 for gnu-help-gnu-emacs@m.gmane.org; Fri, 14 Feb 2003 11:10:55 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.ycc.yale.edu!rum.cs.yale.edu!rum.cs.yale.edu Original-Newsgroups: gnu.emacs.help Original-Lines: 24 Original-NNTP-Posting-Host: rum.cs.yale.edu User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-Original-NNTP-Posting-Host: rum.cs.yale.edu X-Original-Trace: 14 Feb 2003 10:55:08 -0500, rum.cs.yale.edu Original-Xref: shelby.stanford.edu gnu.emacs.help:110191 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:6692 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6692 > somehow I can't believe it. When I try to replace a regexp in a string > I have to create a temporary buffer and use the usual buffer > replacement commands or write a loop over the sequence. Is that true? > I have found a posting in this group describing that and have looked > at the XEmacs sources of subr.el where a defun replace-in-string is > defined which does one of the above procedures depending on the length > of the string. Having coded in Perl a good deal this seems quite > strange to me, but if it is the elispish way to do it, I'll give in I'm not sure what's your complaint exactly. Is it that XEmacs' replace-in-string is not standard in Emacs (this is addressed in Emacs-21 with replace-regexp-in-string) or is it that you find both implementations of replace-in-string inefficient (how is it implemented in Perl) ? Finally, the reason why it took so long for Emacs to provide replace-regexp-in-string is because Emacs uses buffers a lot more than strings, so if you need replace-regexp-in-string it's maybe because you made the arguably wrong decision to use a string rather than a buffer. Perl is great with strings, Emacs is great with buffers. Stefan