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

II. Answers > H. Answers to Chapter 8 Exercises

Appendix H. Answers to Chapter 8 Exercises

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.

Answer 8.1: The regular expression is just the character class that contains those letters. Put the letters between the []:

m/[abx]/

To make it case insensitive, add the uppercase characters, too. There is an easier way to do this, but Learning Perl doesn’t show you that until Chapter 9:

m/[abxABX]/

You could have also done this problem with an alternation, although I told you to use a character class. The alternation works, but it’s a lot more work, not only for you to type but for Perl to run it:


  

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