Emacs Lisp: Trim String
Emacs 24.4 New String Functions
Emacs 24.4 added many string functions. [see Emacs 24.4 Features (released 2014-10)]
These are new string functions:
string-blank-p
string-empty-p
string-join
string-reverse
string-trim-left
string-trim-right
string-trim
string-remove-prefix
string-remove-suffix
To use them, you need to first (require 'subr-x)
.
(require 'subr-x) (string-trim " something ") ; ⇒ "something"
Note: these functions are not documented and are kinda experimental. In the file header, it says it shouldn't be documented.
;; Do not document these functions in the lispref. ;; http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01006.html
See also: Emacs Lisp Problems: Trim String, Regex Match Data, Lacking Namespace