11. Regular Expressions


Regular expressions provide a very powerful way to describe general patterns in text. This chapter only provides a quick reference for regular expressions. See Section 9.9.2 for an explanation of what regular expressions are, what they are useful for, and for more realistic examples of their usage. Small examples are provided throughout this chapter in order to demonstrate the meaning of various features of regular expressions. In each case, a regular expression will be used to search for a pattern within the following text:
The cat sat on the mat.
A successful match will be indicated by highlighting the matched letters within the text. For example, if the pattern being searched for is the word "on", the the result will be displayed as shown below, with the pattern on the left and the resulting match(es) on the right.
"on" \(\Rightarrow\) The cat sat on the mat.



Subsections

Paul Murrell

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 New Zealand License.