Function: string-remove-suffix

string-remove-suffix is a byte-compiled function defined in subr-x.el.gz.

Signature

(string-remove-suffix SUFFIX STRING)

Documentation

Remove SUFFIX from STRING if present.

Other relevant functions are documented in the string group.

Probably introduced at or before Emacs version 24.4.

Shortdoc

;; string
(string-remove-suffix "bar" "foobar")
    => "foo"

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/subr-x.el.gz
(defsubst string-remove-suffix (suffix string)
  "Remove SUFFIX from STRING if present."
  (declare (pure t) (side-effect-free t))
  (if (string-suffix-p suffix string)
      (substring string 0 (- (length string) (length suffix)))
    string))