re-search-forward function is very like the
search-forward function. (See The
re-search-forward searches for a regular expression. If the
search is successful, it leaves point immediately after the last
character in the target. If the search is backwards, it leaves point
just before the first character in the target. You may tell
re-search-forward to return
t for true. (Moving point
is therefore a ‘side effect’.)
re-search-forward function takes
nilas the third argument causes the function to signal an error (and print a message) when the search fails; any other value causes it to return
nilif the search fails and
tif the search succeeds.
re-search-forwardto search backwards.
The template for
re-search-forward looks like this:
(re-search-forward "regular-expression" limit-of-search what-to-do-if-search-fails repeat-count)
The second, third, and fourth arguments are optional. However, if you want to pass a value to either or both of the last two arguments, you must also pass a value to all the preceding arguments. Otherwise, the Lisp interpreter will mistake which argument you are passing the value to.
forward-sentence function, the regular expression will be
the value of the variable
sentence-end. In simple form, that is:
"[.?!]\"')}]*\\($\\| \\| \\)[ ]*"
The limit of the search will be the end of the paragraph (since a
sentence cannot go beyond a paragraph). If the search fails, the
function will return
nil; and the repeat count will be provided
by the argument to the