[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: |
Wed, 28 Jun 2006 13:52:30 +0200 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20060423) |
Kim F. Storm wrote:
>Looks good to me.
>
>But I think examples belong in the manual, not in the doc string.
>
>
It seems that there are no more objections. Can I install?
*** /home/lh/cvsroot/emacs/lisp/subr.el 2006-06-13 12:37:24.000000000 +0200
--- subr.el 2006-06-28 13:44:50.916887229 +0200
***************
*** 2615,2620 ****
--- 2615,2636 ----
;;;; Replacement in strings.
+ (defconst string-strip-default-white-space "[ \f\t\n\r\v]*"
+ "The default value of white-space for `string-strip'.
+ A regexp matching strings of white space.")
+
+ (defun string-strip (string &optional white-space)
+ "Remove leading and trailing WHITE-SPACE from STRING.
+ If WHITE-SPACE is non-nil, it should be a regular expression matching white
+ space. If nil it defaults to `string-strip-default-white-space', normally
+ \"[ \\f\\t\\n\\r\\v]*\"."
+ (let ((ws (or white-space string-strip-default-white-space)))
+ (save-match-data
+ (string-match
+ (concat "\\`\\(?:" ws "\\)\\(\\(?:.\\|\n\\)*?\\)\\(?:" ws "\\)\\'")
+ string)
+ (match-string 1 string))))
+
(defun subst-char-in-string (fromchar tochar string &optional inplace)
"Replace FROMCHAR with TOCHAR in STRING each time it occurs.
Unless optional argument INPLACE is non-nil, return a new string."
- Re: string-strip, (continued)
- 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
- Re: string-strip,
Lars Hansen <=
- Re: string-strip, Juri Linkov, 2006/06/28
- Re: string-strip, Richard Stallman, 2006/06/29
string-strip, Andreas Roehler, 2006/06/20