emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string-strip


From: Andreas Roehler
Subject: string-strip
Date: Tue, 20 Jun 2006 12:26:11 +0200
User-agent: Thunderbird 1.5.0.4 (X11/20060516)

Looks great. Thanks.

Here with this example included:

(defun string-strip (str)
 "Return a copy of STR with leading and trailing white space removed.

\(string-strip \" foo \")      => \"foo\"
\(string-strip \" \\nfoo\\n \")  => \"foo\"
\(string-strip \" foo\\nbar \") => \"foo\\nbar\"
\(string-strip \" \")          => \"\"
\(string-strip \" \\n \")       => \"\"
"
 (save-match-data
   (string-match
"\\`[[:space:]\n]*\\(\\(?:.\\|\n\\)*?\\)[[:space:]\n]*\\'" str)
   (match-string 1 str)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]