Regular Expressions: From Zero to Regex Hero

Last week I presented this session on Regular Expressions at the Wellington .NET User Group. It was nice to get such a great reception from the audience, and I hope they were able to follow along with the content.

Part of what made this a success was the integration of the technical demos in the presentation. From previous experience presenting at the Silverlight User Group, it can feel awkward having notes in the slides to jump to the demo, and conversely having to remember when to jump back into the slides without taking the demo too far. The task-switching also introduces the potential to inadvertently end the slide show and require paging through many slides to return to the proper point in the presentation.

In the end, I drew inspiration from Bea Stollnitz's WPF presentations, where her slides are developed using WPF instead of PowerPoint. At it's heart, the application uses the Page-based navigation feature of WPF to display the slides.

What I have done is integrate live controls that are able to test/demonstrate regular expressions into the particular slides, making it unnecessary to switch to the IDE. And if you do, the application can be restarted from the slide that was previously shown. A key difference from Bea's implementation is that I use the Model-View-ViewModel design pattern for a greater degree of separation between UI and content. This also allows more slides to be defined than there are distinct WPF Pages; binding to different viewmodels allows each template page to display different content. The real content of the slides (except 'fixed content' slides) is then defined in a single XML file.

I have placed the source for this application, dubbed RegExpress, on CodePlex at This requires Visual C# 2008 or later to build and run. A good spin-off is that aside from providing guidance through the features of regular expressions, RegExpress can also be used to prototype or test regular expressions for particular software tasks, e.g. input string validation, data extraction, and search & replace.

Screenshot of RegExpress interactive slide

Finally, for more detailed info on the inner workings of regular expressions, I highly recommend visiting This is essentially the 'Bible' of Regular Expressions, and is great for walking through how regular expressions work behind-the-scenes. It is worth knowing about these details, as the understanding makes it easier to compose expressions on-the-fly to solve custom problems, or to determine why a particular expression might not be working properly.

After all, there is often a case where regular expressions will help you save the day.