7. Regular Expressions, Part II

Regular expressions are such a big subject in Python that it’s hard to cover it all in one chapter. This chapter explores the finer points of the Python regular-expression grammar.

One of the most useful advanced features of Python is the Scanner class. It’s little known and little documented. The last couple of sections in this chapter explain the use of this feature at length. Once you understand it, you’ll find it an extremely useful tool. It’s a way of directing specific patterns to be associated with specific kinds of tokens and then taking the appropriate action.

7.1 Summary of Advanced RegEx Grammar

Table 7.1 summarizes the advanced grammar introduced in this chapter. The subsequent sections explain how ...

Get Supercharged Python: Take Your Code to the Next Level, First 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.