Appendix A. Simple Regular Expressions

This appendix examines some basic aspects of constructing regular expressions. One reason for working through the simple regular expressions presented in this chapter is to illuminate the regular expressions used in Chapter 3 and further extend your knowledge of regular expressions.

The following exercises use OpenOffice.org Writer — a free document editor that makes it easy to apply regular expressions to text, and verify that they do what you expected. You can download this tool from http://www.openoffice.org.

Note

This appendix has been "borrowed" from Beginning Regular Expressions (Wiley Publishing, Inc., 2005) by Andrew Watt. We recommend this book for further (and more comprehensive) reference into the world of regular expressions.

The examples used are necessarily simple, but by using regular expressions to match fairly simple text patterns, you should become increasingly familiar and comfortable with the use of foundational regular expression constructs that can be used to form part of more complex regular expressions. Other chapters explore additional regular expression constructs and address progressively more complex problems.

One of the issues this chapter explores in some detail is the situation where you want to match occurrences of characters other than those characters simply occurring once.

This chapter looks at the following:

  • How to match single characters

  • How to match optional characters

  • How to match characters that can occur an unbounded ...

Get Professional Search Engine Optimization with ASP.NET: A Developer's Guide to SEO now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.