Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 12. Regular Expressions > Using the RegExp Class

12.7. Using the RegExp Class

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.

12.7.1. Building Dynamic Expressions with String Operations

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial