Appendix A. Simple Regular Expressions
This appendix examines some basic aspects of constructing regular expressions. One reason for working through the simple examples presented in this appendix is to illuminate the regular expressions used in Chapter 3 and further extend your knowledge of them.
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 the Wrox title Beginning Regular Expressions (Wiley, 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.
One of the issues this appendix explores in some detail is the situation where you want to match occurrences of characters other than those characters simply occurring once.
This appendix looks at the following:
How to match single characters
How to match optional characters
How to match characters that can occur an unbounded number of times, whether the characters of interest are optional or required
How to match characters that can occur a specified number ...
Get Professional Search Engine Optimization with PHP: 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.