From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Benjamin Lewis Newsgroups: gmane.emacs.help Subject: Re: left-trim and right-trim for strings Date: Mon, 23 Sep 2002 22:24:37 -0700 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=us-ascii X-Trace: main.gmane.org 1032846397 21693 127.0.0.1 (24 Sep 2002 05:46:37 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 24 Sep 2002 05:46:37 +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 17tiWq-0005dl-00 for ; Tue, 24 Sep 2002 07:46:36 +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 17tiWu-0001jA-00; Tue, 24 Sep 2002 01:46:40 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-han1.dfn.de!news-stu1.dfn.de!news.belwue.de!LF.net!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: css.css.sfu.ca Original-X-Trace: quimby.gnus.org 1032847714 23382 199.60.1.20 (24 Sep 2002 06:08:34 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: 24 Sep 2002 06:08:34 GMT X-Attribution: Benjamin Lewis X-Yow: My pants just went to high school in the Carlsbad Caverns!!! User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.1 (sparc-sun-solaris2.8) Cancel-Lock: sha1:NqaIef74nMUtRWX0Ix+tPoWwI2o= Original-Xref: nntp.stanford.edu gnu.emacs.help:105217 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:1772 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1772 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. ") > `---- Hey, cool. You could do (replace-regexp-in-string "[ \t\n]+" " " " This is another string. ") to remove doubled spaces. -- Benjamin Lewis Don't take life so serious, son, it ain't nohow permanent. -- Walt Kelly