Function: re-search-backward

re-search-backward is an interactive function defined in search.c.

Signature

(re-search-backward REGEXP &optional BOUND NOERROR COUNT)

Documentation

Search backward from point for regular expression REGEXP.

This function is almost identical to re-search-forward, except that by default it searches backward instead of forward, and the sign of COUNT also indicates exactly the opposite searching direction. See re-search-forward for details.

Note that searching backwards may give a shorter match than expected, because REGEXP is still matched in the forward direction. See Info anchor (elisp) re-search-backward for details.

Other relevant functions are documented in the regexp group.

View in manual

Probably introduced at or before Emacs version 19.29.

Key Bindings

Shortdoc

;; regexp
(re-search-backward "^foo$" nil t)
    e.g. => 43

Aliases

search-backward-regexp

Source Code

// Defined in /usr/src/emacs/src/search.c
{
  return search_command (regexp, bound, noerror, count, -1, true, false);
}