GNU Info

Info Node: (emacs-lisp-intro.info)Regexp Search

(emacs-lisp-intro.info)Regexp Search


Next: Counting Words Prev: Loops & Recursion Up: Top
Enter node , (file) or (file)node

Regular Expression Searches
***************************

   Regular expression searches are used extensively in GNU Emacs.  The
two functions, `forward-sentence' and `forward-paragraph', illustrate
these searches well.  They use regular expressions to find where to
move point.  The phrase `regular expression' is often written as
`regexp'.

   Regular expression searches are described in Note: Regular
Expression Search, as well as in Note: Regular
Expressions.  In writing this chapter, I am
presuming that you have at least a mild acquaintance with them.  The
major point to remember is that regular expressions permit you to
search for patterns as well as for literal strings of characters.  For
example, the code in `forward-sentence' searches for the pattern of
possible characters that could mark the end of a sentence, and moves
point to that spot.

   Before looking at the code for the `forward-sentence' function, it
is worth considering what the pattern that marks the end of a sentence
must be.  The pattern is discussed in the next section; following that
is a description of the regular expression search function,
`re-search-forward'.  The `forward-sentence' function is described in
the section following.  Finally, the `forward-paragraph' function is
described in the last section of this chapter.  `forward-paragraph' is
a complex function that introduces several new features.

sentence-end
The regular expression for `sentence-end'.
re-search-forward
Very similar to `search-forward'.
forward-sentence
A straightforward example of regexp search.
forward-paragraph
A somewhat complex example.
etags
How to create your own `TAGS' table.
Regexp Review
re-search Exercises

automatically generated by info2www version 1.2.2.9