Next: Counting Words, Previous: Loops & Recursion, Up: Top [Contents][Index]
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 Regular
Expression Search in The GNU Emacs Manual, as well as in Regular
Expressions in The GNU Emacs Lisp Reference Manual. 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. | |
• Regexp Review | ||
• re-search Exercises |
Next: Counting Words, Previous: Loops & Recursion, Up: Top [Contents][Index]