Function: string-trim-left

string-trim-left is a byte-compiled function defined in subr.el.gz.

Signature

(string-trim-left STRING &optional REGEXP)

Documentation

Trim STRING of leading string matching REGEXP.

REGEXP defaults to "[ \\t\\n\\r]+".

Other relevant functions are documented in the string group.

View in manual

Probably introduced at or before Emacs version 24.4.

Shortdoc

;; string
(string-trim-left "oofoo" "o+")
    => "foo"

Aliases

url-strip-leading-spaces (obsolete since 29.1)

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun string-trim-left (string &optional regexp)
  "Trim STRING of leading string matching REGEXP.

REGEXP defaults to \"[ \\t\\n\\r]+\"."
  (declare (important-return-value t))
  (if (string-match (if regexp
                        (concat "\\`\\(?:" regexp "\\)")
                      "\\`[ \t\n\r]+")
                    string)
      (substring string (match-end 0))
    string))