www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_185.html   search  
Buy the book!

Programming in Emacs Lisp

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12. 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 section `Regular Expression Search' in The GNU Emacs Manual, as well as in section `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.

12.1 The Regular Expression for sentence-end  The regular expression for sentence-end.
12.2 The re-search-forward Function  Very similar to search-forward.
12.3 forward-sentence  A straightforward example of regexp search.
12.4 forward-paragraph: a Goldmine of Functions  A somewhat complex example.
12.5 Create Your Own `TAGS' File  How to create your own `TAGS' table.
12.6 Review  
12.7 Exercises with re-search-forward  

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003