June 2002
Beginner to intermediate
640 pages
14h 24m
English
Let's say that you're looking for a job in the newspaper and you've decided to narrow your focus to ads that say, “Money is no object.” This is the pattern you're searching for, and of course you're looking in the employment section, which is the group of characters you're searching in. You don't care where you find your pattern, only that it's there.
If you were writing a Python program to help you find a job, it would start out looking like this:
>>> from re import *
mino = compile("money is no object");
for ad in classifieds:
if(mino.search(ad)):
print ad;
Let's work through this example interactively.
Import the re module.
>>> from re import *
Import class re.
>>> classifieds = ["School Teacher; salary $20,000.","Engineer; ...
Read now
Unlock full access