You are on page 1of 17

Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Publications of David Mertz * Technical Publications * Gnosis Software Home


Page * My book: Text Processing in Python

Reg ular Exp ressio ns XM L Reg ular Exp ressio ns Better Email M arketing Neuro p sycho lo g y D eg ree
C heatSheet on pages 14-15 Edit R egular Exp's for XML R ich functionality, deep Find The U.S. Neuropsychology
C olor-coded brow ser Schema XML Editor. Try for Free reporting, on-demand Program R ight For You. Visit
compatibility Today! consulting. Upgrade Today Now !
VisiBone.com/Brow serBook w w w .Altova.com/XMLSpy w w w .EmailLabs.com AllPsychologySchools.com

Introduction to the Tutorial

Sob story: This page seems to be quite widely read, but only just occasionally gets
donations on the above Paypal link. Tragedy of the commons and all that... but still, if
any of you would like to donate a buck or two, I'd appreciate it?
Anyway, this tutorial was first published by IBM developerWorks. This version contains
a few minor corrections that readers have suggested since the original publication. An
expanded and updated version can be found in my book, Text Processing in Python

Navigation

Who is this tutorial for?

1 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Just what is a regular expression anyway?

What tools use regular expressions?

2 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Note on presentation

3 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Contact

Where to go from here...

Matching Patterns in Text: The Basics

Character literals

4 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

"Escaped" characters literals

Positional special characters

5 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

The "wildcard" character

Grouping regular expressions

Character classes

6 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Complement operator

Alternation of patterns

7 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

The basic abstract quantifier

Matching Patterns in Text: Intermediate

More abstract quantifiers

8 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Numeric quantifiers

Backreferences

9 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Don't match more than you want to

Tricks for restraining matches

10 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Comments on modification tools

A note on modification examples

11 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

A literal-string modification example

A pattern-match modification example

Modification using backreferences

12 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Another warning on mismatching

Advanced Regular Expression


Extensions

About advanced features

13 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Non-greedy quantifiers

Pattern-match modifiers

14 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Changing backreference behavior

Naming backreferences

15 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

Lookahead assertions

Making regular expressions more readable

16 of 17 10/06/08 12:25 PM
Learning to Use Regular Expressions http://gnosis.cx/publish/programming/regular_expres...

MSIE sucks

17 of 17 10/06/08 12:25 PM

You might also like