Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In the examples in this chapter, you have seen regular expressions written as literals. However, using regular expressions as RegExp objects enables you to apply some useful techniques and gain important insight.
Keep in mind that if you use the RegExp constructor to create expressions, you can pass in an arbitrary String for the source of the pattern. This means that you can, using String manipulation, programmatically craft a pattern to fit the situation at hand, as shown in Example 12-11.