O'Reilly logo

Core Python Applications Programming, Third Edition by Wesley J. Chun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required