(string-remove-suffix): New function.
*** `string-trim-left'
*** `string-trim-right'
*** `string-trim'
+*** `string-remove-prefix'
+*** `string-remove-suffix'
** Obsoleted functions:
*** `log10'
* emacs-lisp/subr-x.el: Renamed from helpers.el.
helpers.el was a poor choice of name.
+ (string-remove-prefix): New function.
+ (string-remove-suffix): New function.
2013-12-20 Martin Rudalics <rudalics@gmx.at>
"Check whether STRING is either empty or only whitespace."
(string-match-p "\\`[ \t\n\r]*\\'" string))
+(defsubst string-remove-prefix (prefix string)
+ "Remove PREFIX from STRING if present."
+ (if (string-prefix-p prefix string)
+ (substring string (length prefix))
+ string))
+
+(defsubst string-remove-suffix (suffix string)
+ "Remove SUFFIX from STRING if present."
+ (if (string-suffix-p suffix string)
+ (substring string 0 (- (length string) (length suffix)))
+ string))
+
(provide 'subr-x)
;;; subr-x.el ends here