next up previous
Next: Rules for forming (basic) Up: Lab 3: Regular expressions. Previous: Introduction

Regular Expressions (RE)

RE is a way of describing a set of strings without having to list all the strings in your set. RE contains instructions on how to match the pattern. This is accomplished by using plain text and special tokens. A sample RE may look like:
hello
This matches any bit of text which contain hello. It will not match "Hello" in "Hello, world" since REs are case sensitive. REs may also contain tokens. These tokens are used in place of other text. For example hel*o is a RE, where * is a token. As we will see later, * means 0 or more repetitions of the previous character. Our RE will match heo, as well as helo, hello or hellllllllo.

REs are used by many UNIX programs (grep, egrep, sed, perl, vi, emacs etc.). Tokens may vary from program to program and you should refer to manual for the program to see, which tokens are supported. However the following table gives the basic rules used by most programs:



Subsections

Instructional Support Group 2008-08-05