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
Share this Page URL
Help

I. Exercises > 8. Matching with Regular Expressions

Chapter 8. Matching with Regular Expressions

In Chapter 7, you used the same basic program to test all of the regular expressions. Instead of copying that into every answer for this chapter, I’ll just give you the regular expressions and you can plug them into the program yourself.

8.1. Write a regular expression to match an “a”,"b”, or “x” in a string. Use a character class. After you do that, make it case insensitive. (Answer to Exercise 8.1)

8.2. Modify the regular expressions from Exercise 8.1 to match the “a”, “b”, or “x” at the beginning of the string. After that, modify it to match any of those characters at the end of the string. (Answer to Exercise 8.2)

8.3. Modify your regular expression from Exercise 8.2 to match a non-empty string that doesn’t have an “a”, “b”, or “x” at the beginning of the string. Change it again so the regular expression matches a non-empty string that doesn’t have those same characters at the end of the string. (Answer to Exercise 8.3)


  

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


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