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
  • PrintPrint

Exercises

See Section A.7 for answers to the following exercises. These exercises are among the most challenging in the entire book. But don’t get too discouraged! The following chapters will actually be easier, partly because you’ll have the power of regular expressions to help you.

  1. [4] Using the test program from the previous chapter, make a pattern that matches only lines containing either the word fred or wilma, followed by some whitespace, and then the word flintstone. So it should match the string I am fred flintstone (with one or more spaces or tabs between the names).

  2. [10] Here, we give you the answer; you decide what problem it’s trying to solve. What do these real-world patterns match? What might they be used for?

    /"([^"]*)"/
    /^0?[0-3]?[0-7]{1,2}$/
    /^\b[\w.]{1,12}\b$/

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint