Appendix A. Answers to Selected Exercises

The Answer to the Great Question... Of Life, the Universe and Everything... Is... Forty-two, said Deep Thought, with infinite majesty and calm.

—Douglas Adams, October 1979(from The Hitchhiker’s Guide to theGalaxy, 1979, Pan Books)

Chapter 1

Regular Expressions

1-1. Matching strings

bat, hat, bit, etc.

[bh][aiu]t

1-2. First name last

[A-Za-z-]+ [A-Za-z-]+

(Any pair of words separated by a single space, that is, first and last names, hyphens allowed)

1-3. Last name first

[A-Za-z-]+, [A-Za-z]

(Any word and single letter separated by a comma and single space, as in, last name, first initial)

[A-Za-z-]+, [A-Za-z-]+

(Any pair of words separated by a comma and single space, such as, last, first names, hyphens ...

Get Core Python Applications Programming, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.