Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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: