Function: string-prefix-p
string-prefix-p is a byte-compiled function defined in subr.el.gz.
Signature
(string-prefix-p PREFIX STRING &optional IGNORE-CASE)
Documentation
Return non-nil if STRING begins with PREFIX.
PREFIX should be a string; the function returns non-nil if the characters at the beginning of STRING compare equal with PREFIX. If IGNORE-CASE is non-nil, the comparison is done without paying attention to letter-case differences.
Other relevant functions are documented in the string group.
Probably introduced at or before Emacs version 24.1.
Shortdoc
;; string
(string-prefix-p "foo" "foobar")
=> t
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun string-prefix-p (prefix string &optional ignore-case)
"Return non-nil if STRING begins with PREFIX.
PREFIX should be a string; the function returns non-nil if the
characters at the beginning of STRING compare equal with PREFIX.
If IGNORE-CASE is non-nil, the comparison is done without paying attention
to letter-case differences."
(declare (side-effect-free t))
(let ((prefix-length (length prefix)))
(if (> prefix-length (length string)) nil
(eq t (compare-strings prefix 0 prefix-length string
0 prefix-length ignore-case)))))