[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string-strip
From: |
Lars Hansen |
Subject: |
Re: string-strip |
Date: |
Tue, 20 Jun 2006 08:34:15 +0200 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20060423) |
Richard Stallman wrote:
> > 3. Return nil when resulting string is empty.
>
>That would be a bad idea.
>
>
Ok. Then what about
(defun string-strip (str)
"Return a copy of STR with leading and trailing white space removed."
(save-match-data
(string-match
"\\`[[:space:]\n]*\\(\\(?:.\\|\n\\)*?\\)[[:space:]\n]*\\'" str)
(match-string 1 str)))
(string-strip " foo ") => "foo"
(string-strip " \nfoo\n ") => "foo"
(string-strip " foo\nbar ") => "foo\nbar"
(string-strip " ") => ""
(string-strip " \n ") => ""
- string-strip, Andreas Roehler, 2006/06/17
- Re: string-strip, Richard Stallman, 2006/06/19
- Re: string-strip, Lars Hansen, 2006/06/19
- Re: string-strip, Richard Stallman, 2006/06/19
- Re: string-strip,
Lars Hansen <=
- Re: string-strip, Richard Stallman, 2006/06/20
- Re: string-strip, Andreas Roehler, 2006/06/20
- Re: string-strip, Nick Roberts, 2006/06/20
- Re: string-strip, Kim F. Storm, 2006/06/20
- Re: string-strip, Nick Roberts, 2006/06/20
- Re: string-strip, Johan Bockgård, 2006/06/20
- Re: string-strip, Lars Hansen, 2006/06/21
- Re: string-strip, Kim F. Storm, 2006/06/22
- Re: string-strip, Andreas Roehler, 2006/06/22
- Re: string-strip, Kim F. Storm, 2006/06/22