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.
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)