(lemacs.info)Regexp Search

Next: Regexps Prev: Word Search Up: Search

Regular Expression Search

   A "regular expression" ("regexp", for short) is a pattern that
denotes a set of strings, possibly an infinite set.  Searching for
matches for a regexp is a powerful operation that editors on Unix
systems have traditionally offered.  In GNU Emacs, you can search for
the next match for a regexp either incrementally or not.

   Incremental search for a regexp is done by typing `C-M-s'
(`isearch-forward-regexp').  This command reads a search string
incrementally just like `C-s', but it treats the search string as a
regexp rather than looking for an exact match against the text in the
buffer.  Each time you add text to the search string, you make the
regexp longer, and the new regexp is searched for.  A reverse regexp
search command `isearch-backward-regexp' also exists, but no key runs

   All of the control characters that do special things within an
ordinary incremental search have the same functionality in incremental
regexp search.  Typing `C-s' or `C-r' immediately after starting a
search retrieves the last incremental search regexp used: incremental
regexp and non-regexp searches have independent defaults.

   Non-incremental search for a regexp is done by the functions
`re-search-forward' and `re-search-backward'.  You can invoke them with
`M-x' or bind them to keys.  You can also call `re-search-forward' by
way of incremental regexp search with `C-M-s RET'.

automatically generated by info2www