June 2002
Beginner to intermediate
640 pages
14h 24m
English
A pattern can be as small as one character (as in the previous example), matching only itself, or of almost any length. It can contain wildcard and special characters, subexpressions, and so forth, depending on system resources.
Our expression “money is no object” is a string of literal characters requiring an exact match in the exact order, but regular expressions can be much more powerful. Say, for example, that you're looking for a job whose salary figure is within a certain range—that is, with a certain number of digits to the left of the decimal. To find all records with two digits before the comma and three digits after, you can write this expression:
>>> reStr = r'\$..,...\.'
Then you can compile and match it ...
Read now
Unlock full access