Main index

Introducing UNIX and Linux


Overview
Using filters
      Collating sequence
      Character classes
Character-to-character transformation
Selecting lines by content
      Regular expressions
      Basic regular expressions
      Extended regular expressions
      Grep
Stream editor
      Sed addresses
Splitting a file according to context
Choosing between the three filters
More on Vi
Summary
Exercises

Regular expressions

The pattern matching described earlier is a very simple means of associating many strings which have a common pattern with a single string that describes that pattern. It is fine for matching filenames, and for the use of a case statement. However, a more powerful mechanism, known as regular expressions or REs, is available for use in certain UNIX utilities.

There are different types of regular expression, and regular expressions can be defined in a variety of ways. UNIX specifies two sorts - a basic regular expression (or BRE), and an extended regular expression (or ERE). We start by defining a basic regular expression.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck