Function: isearch-symbol-regexp
isearch-symbol-regexp is a byte-compiled function defined in
isearch.el.gz.
Signature
(isearch-symbol-regexp STRING &optional LAX)
Documentation
Return a regexp which matches STRING as a symbol.
Creates a regexp where STRING is surrounded by symbol delimiters \_< and \_>. If there are more than one symbol, then compute a regexp that matches those exact symbols separated by non-symbol characters. If the string begins or ends in whitespace, the beginning or the end of the string matches arbitrary non-symbol whitespace. Otherwise if LAX is non-nil, the beginning or the end of the string need not match a symbol boundary.
Source Code
;; Defined in /usr/src/emacs/lisp/isearch.el.gz
;; Symbol search
(defun isearch-symbol-regexp (string &optional lax)
"Return a regexp which matches STRING as a symbol.
Creates a regexp where STRING is surrounded by symbol delimiters \\_< and \\_>.
If there are more than one symbol, then compute a regexp that matches
those exact symbols separated by non-symbol characters. If the string
begins or ends in whitespace, the beginning or the end of the string
matches arbitrary non-symbol whitespace. Otherwise if LAX is non-nil,
the beginning or the end of the string need not match a symbol boundary."
(let ((not-word-symbol-re
;; This regexp matches all syntaxes except word and symbol syntax.
"\\(?:\\s-\\|\\s.\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s/\\|\\s$\\|\\s'\\|\\s<\\|\\s>\\|\\s!\\|\\s|\\)+"))
(cond
((equal string "") "")
((string-match-p (format "\\`%s\\'" not-word-symbol-re) string)
not-word-symbol-re)
(t (concat
(if (string-match-p (format "\\`%s" not-word-symbol-re) string)
not-word-symbol-re
"\\_<")
(mapconcat 'regexp-quote (split-string string not-word-symbol-re t)
not-word-symbol-re)
(if (string-match-p (format "%s\\'" not-word-symbol-re) string)
not-word-symbol-re
(unless lax "\\_>")))))))