Commit b55aea38 authored by Bozhidar Batsov's avatar Bozhidar Batsov
Browse files

* lisp/emacs-lisp/helpers.el: Add some string helpers.

(string-trim-left): Removes leading whitespace.
(string-trim-right): Removes trailing whitespace.
(string-trim): Removes leading and trailing whitespace.
parent 41ce6f70
......@@ -769,6 +769,9 @@ frame.
** New library helpers.el for misc helper functions
*** `hash-table-keys'
*** `hash-table-values'
*** `string-trim-left'
*** `string-trim-right'
*** `string-trim'
** Obsoleted functions:
*** `log10'
......
2013-11-24 Bozhidar Batsov <bozhidar@batsov.com>
* emacs-lisp/helpers.el: Add some string helpers.
(string-trim-left): Removes leading whitespace.
(string-trim-right): Removes trailing whitespace.
(string-trim): Removes leading and trailing whitespace.
* subr.el (string-suffix-p): New function.
2013-11-23 Glenn Morris <rgm@gnu.org>
......
......@@ -37,6 +37,22 @@
(maphash (lambda (_k v) (push v values)) hash-table)
values))
(defsubst string-trim-left (string)
"Remove leading whitespace from STRING."
(if (string-match "\\`[ \t\n\r]+" string)
(replace-match "" t t string)
string))
(defsubst string-trim-right (string)
"Remove trailing whitespace from STRING."
(if (string-match "[ \t\n\r]+\\'" string)
(replace-match "" t t string)
string))
(defsubst string-trim (string)
"Remove leading and trailing whitespace from STRING."
(string-trim-left (string-trim-right string)))
(provide 'helpers)
;;; helpers.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment