Node:fwd-sentence re-search, Previous:fwd-sentence while loops, Up:forward-sentence
The re-search-forward
function searches for the end of the
sentence, that is, for the pattern defined by the sentence-end
regular expression. If the pattern is found--if the end of the sentence is
found--then the re-search-forward
function does two things:
re-search-forward
function carries out a side effect, which
is to move point to the end of the occurrence found.
re-search-forward
function returns a value of true. This is
the value received by the if
, and means that the search was
successful.
The side effect, the movement of point, is completed before the
if
function is handed the value returned by the successful
conclusion of the search.
When the if
function receives the value of true from a successful
call to re-search-forward
, the if
evaluates the then-part,
which is the expression (skip-chars-backward " \t\n")
. This
expression moves backwards over any blank spaces, tabs or carriage
returns until a printed character is found and then leaves point after
the character. Since point has already been moved to the end of the
pattern that marks the end of the sentence, this action leaves point
right after the closing printed character of the sentence, which is
usually a period.
On the other hand, if the re-search-forward
function fails to
find a pattern marking the end of the sentence, the function returns
false. The false then causes the if
to evaluate its third
argument, which is (goto-char par-end)
: it moves point to the
end of the paragraph.
Regular expression searches are exceptionally useful and the pattern
illustrated by re-search-forward
, in which the search is the
test of an if
expression, is handy. You will see or write code
incorporating this pattern often.