          GREP (Global Regular Expression Search and Print)

 
I find GREP indispensable when programming so when I started writing
programs for the Amiga, I decided that GREP should be something that
I would be comfortable with. And this is the result of my efforts.

GREP searches through a set of text files for a pattern and prints
each lines containing the pattern. This document will specify the
regular expression as recognised by the program.

1 Searching for a specified pattern

Enter the pattern in the box labelled pattern, select files to
be searched and click on 'SEARCH' to start the search. Any lines 
containing the specified pattern, when found, will be displayed 
in an output window. The output from a search can also be redirected
to a file by specifying a file name in the box labelled output. When
no file name is specified, the default is to open an output window.
   
2 Regular Expressions

2.1 String of characters

  In the simplest form, a pattern is simply a word or string of  
  characters.

2.2 Wildcard character (.)

  The period is a special character. It matches any one character 
  including space,tab,newline or control character. For example,   
  the pattern :
     
  t.p   ('t' followed by any one character, followed by 'p')

  will match top or tip but not trap.

2.3 Closure characters (*,+)

  The asterisk(*) character means 'zero or more of', while the plus 
  sign (+) means 'one or more of' of the character preceding it. 
  The pattern :

  hel*o  (zero or more of the character 'l')

  will mean a successful match on heo, helo or hello but the 
  pattern :

  hel+o  (one or more of the character 'l') 

  will only match helo or hello but not heo.

2.4 Character Classes 

2.4.1 Character Classes Marker ([,])

  A character class pattern is matched by any one character in a 
  given set. The left and right bracket symbols ([]) is used to mark 
  the beginning and end of a character set. 
  The pattern :

  [Hh]ello   ('H' or 'h' followed by 'ello')

  will mean a successful match for 'Hello' or 'hello'
 	
2.4.2 Character Classes Range (-)
	
  Within a character set, the minus symbol ('-') is taken to 
  indicate a range of characters thus the set [a-z] is matched by
  any lowercase letter.

2.4.3 Character Classes Exclusion (!)
	
  The exclamation point (!) is regarded as a negation operator when 
  it occurs as the first character in a character class thus the set 
  [!0-9] is matched by any character excluding a numeric. The !
  character only has the special meaning when it is used as the
  first character in a class.

2.5 Beginning of line character (^)
	
  When the carat character is the first character in a pattern, the 
  pattern will only yield a successful match if it occurs at the
  start of a line.

2.6 End of line character ($)
	
  The dollar sign is similar to the carat character and is used to
  find a pattern that only occurs at the end of a line. 

3.0 Escape character (\)

  All the characters described in the previous section :

  .  *  +  [  ]  -  !  ^  $

  have special meaning to the program. To search for a special
  character itself in a string, the character must be preceded by
  the escape character, the backslash ('\'). For example, to search
  for open square bracket '[', use the pattern \[, where the open
  square bracket is escaped. Similarly, the backslash can be
  searched for by escaping it thus \\.

4.0 Summary

    .          Any one character 
    *          Zero or more of previous character or group
    +          One or more of previous character or group
    [          Begin character class
    ]          End character class
    -          Define range in character class
    !          Excluding character set
    ^          Beginning of line
    $          End of line
    \          Escape character
   
5.0 The program 

   Author :   Huzaifah Zainon
   
   Language : Lattice C V5.0
   
   Date :     October 1991
   
   Version :  1.0
   
   This program is for the public domain and must be distributed 
   with this documentation intact.
   
   