[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: left-trim and right-trim for strings
From: |
maierh |
Subject: |
Re: left-trim and right-trim for strings |
Date: |
Tue, 24 Sep 2002 07:11:17 +0200 |
User-agent: |
Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2.90 (i386-mingw-nt5.0.2195) |
"Stefan Monnier <foo@acm.com>" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>
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. ")
`----
Harald