Introducing Regular Expressions

A regular expression - regex, for short - is a sequence of characters which describes a block of text. A regex does not have to be complicated. After all, any piece of text does fully describe itself and is as a result a valid regular expression. Thus, the sequence ExplainThat matches ExplainThat in the sentence Welcome to ExplainThat! . If this were all a regex could do, it would be of very little use. The true power of regexes arises as a result of their ability to find text matches to patterns containing matching instructions that impose constraints on character placement, order, repetition etc.

Regexes have an unfortunate reputation for being difficult. This is in no small measure because regex syntax is at first glance quite arcane. It is far too easy to make mistakes when typing in a regex. On these pages, we use a color coded regex editor which makes it easier to spot such mistakes. Scan through the topics in this section and experiment with your own regexes using the regex editor - it won't be long before you have the mastery of this powerful programming tool.

Colophon