Pattern Matching Using Regular Expressions

This course describes how patterns in text strings can be matched using regular expressions. A number of programming and scripting languages (such as Python, Perl, and Java) and other applications (such as Apache, PHP, Exim, and some text editors) support the use of regular expression patterns. Although there are some differences between the different implementations, there is also a lot in common.

The course has been modified and extended from the one previously given by Philip Hazel, the author of the PCRE ("Perl Compatible Regular Expressions") library, one of the standard and widely used regular expression libraries. The extensions are: Python and Java to the same level as Perl and PCRE; more warnings about problem areas, background usage and programming hints; and a short section on true (computer science) regular expressions and their uses when transferring data between programs.

Lecture

the handout is the foils reorganised for printing, and is is extended with some relatively esoteric points that most people don't need to know. That is so they can be referred to later, if needed.

The handout

Philip Hazel's Perl regular expression exerciser is an interactive teaching aid, and must be downloaded and run.

The Perl exercise program

There are some Python and Java timing harnesses, similar to pcretest, which may be useful to try out regular expressions, but do not include the interactive aids.

The Python program

The Java program

Books

This is a book on actually using regular expressions, of the sort described in the course. There are probably many others. This edition does not mention Python as such, but earlier ones did.

Mastering Regular Expressions, Third Edition Jeffrey E.F. Friedl, O'Reilly

This is a good book on the theory, but is recommended for mathematicians only.

Introduction to automata theory, languages, and computation by John E. Hopcroft, Rajeev Motwani and Jeffrey D. Ullman, 3rd ed. (2007), Pearson Addison Wesley