Using Regular Expressions
As previously explained, there is no regular expressions program; it is not an application you run nor software you buy or download. Rather, the regular expressions language is implemented in lots of software products, languages, utilities, and development environments.
How regular expressions are used and how regular expression functionality is exposed varies from one application to the next. Some applications use menu options and dialog boxes to access regular expressions, and different programming languages provide functions or classes of objects that expose regex functionality.
Furthermore, not all regular expression implementations are the same. There are often subtle (and sometimes not so subtle) differences between syntax and features.
Appendix A, “Regular Expressions in Popular Applications and Languages,” provides usage details and notes for many of the applications and languages that support regular expressions. Before you proceed to the next lesson, consult that appendix to learn the specifics pertaining to the application or language that you will be using.
To help you get started quickly, you may download a Regular Expression Tester application from this book’s Web page at http://www. forta. com/books/0672325667/. The application is Web based, and there are versions for use with popular application servers and languages, as well as with straight JavaScript. The application is described in Appendix C, “The Regular Expression Tester,” and can be immensely useful in experimenting with regular expressions quickly and easily.
Before You Get Started
Before you go any further, take note of a couple of important points:
When using regular expressions, you will discover that there are almost always multiple solutions to any problem. Some may be simpler, some may be faster, some may be more portable, and some may be more capable. There is rarely a right or wrong solution when writing regular expressions (as long as your solution works, of course).
As already stated, differences exist between regex implementations. As much as possible, the examples and lessons used in this book apply to all major implementations, and differences or incompatibilities are noted as such.
As with any language, the key to learning regular expressions is practice, practice, practice.
Note
I strongly suggest that you try each and every example as you work through this book.