From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Klaus Berndl Newsgroups: gmane.emacs.help Subject: Re: left-trim and right-trim for strings Date: 24 Sep 2002 15:09:18 +0200 Organization: UTA/netway (Customer) Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <5l3cs0o88m.fsf@rum.cs.yale.edu> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1032873982 24776 127.0.0.1 (24 Sep 2002 13:26:22 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 24 Sep 2002 13:26:22 +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 17tphh-0006R5-00 for ; Tue, 24 Sep 2002 15:26:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17tphl-0004M2-00; Tue, 24 Sep 2002 09:26:21 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed.r-kom.de!newsfeed.completel.de!news.netway.at!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 44 Original-NNTP-Posting-Host: 195.96.24.28 Original-X-Trace: newsreader1.netway.at 1032873149 23831 195.96.24.28 (24 Sep 2002 13:12:29 GMT) Original-X-Complaints-To: abuse@netway.at Original-NNTP-Posting-Date: 24 Sep 2002 13:12:29 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 X-Forwarded: by - (DeleGate/7.5.3) Original-Xref: nntp.stanford.edu gnu.emacs.help:105230 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:1786 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1786 On Tue, 24 Sep 2002, maierh@myself.com wrote: > > "Stefan Monnier " > writes: > > > How ironic. You used `split-string' just where `string-match' makes > > more sense and then use `string-match' where `split-string' is just what > > you need: > > > Why not > > > > (if (string-match "\\`[\n\t ]+" str) (substring str (match-end 0)) str) > > ? > > or > > (if (string-match "\\`[\n\t ]*" str) (substring str (match-end 0))) ? > > > > Since emacs-21 we have too `replace-regexp-in-string'. Personally, I > like it very much. > > ,---- > | (replace-regexp-in-string "^ *" "" " This is a string. ") > `---- Eureka! Yes, indeed, this is the one and only solution. It can be used for left- right- and middle-trim without any if etc...Great. But why are such trimming functions not included in the elisp-library? IMHO they would be very useful for elisp-programmers?! Klaus P.S. Nevertheless Stefans adjudgement about my first using of string-match and split-string is correct ;-) -- Klaus Berndl mailto: klaus.berndl@sdm.de sd&m AG http://www.sdm.de software design & management Thomas-Dehler-Str. 27, 81737 München, Germany Tel +49 89 63812-392, Fax -220