6.10.2 Grep

One external tool in the Tools menu is already predened: a menu item to call the grep utility ("Tools|Grep" or Shift-F2). Grep searches for a given string in les and returns the lines which contain the string. The search string can be even a regular expression. For this menu item to work, the grep program must be installed, since it does not come with Free Pascal.

The messages window displayed in gure (6.17) in the previous section shows the output of a typical grep session. The messages window can be used in combination with grep to nd special occurrences in the text.

Grep supports regular expressions. A regular expression is a string with special characters which describe a whole class of expressions. The command line in dos or linux have limited support for regular expressions: entering ls *.pas (or dir *.pas) to get a list of all Pascal les in a directory. *.pas is something similar to a regular expression. It uses a wildcard to describe a whole class of strings: those which end on ".pas". Regular expressions oer much more: for example [A-Z][0-9]+ describes all strings which begin with a upper case letter followed by one or more digits.

It is outside the scope of this manual to describe regular expressions in great detail. Users of a linux system can get more information on grep using man grep on the command-line.