Skip to content

Commit

Permalink
Improvements to the Introduction and Simple Patterns sections of inte…
Browse files Browse the repository at this point in the history
…rmediate/regex.

Main changes:
- Fixed the links to other sections and the Glossary.
- Added files containing the 'evil' data to data/evil.
- Created some exercises for the Simple Patterns section.
- Corrected a few typos and made some paragraphs clearer.
- Split up the Simple Patterns section into subsections.
- Added the intermediate/regex section to the Makefile.
- Added an index page.
  • Loading branch information
Christian Jacobs committed Jul 31, 2014
1 parent b11e23f commit d8429f7
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 110 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ MOST_SRC = \
# All source pages (including things not in the book).
ALL_SRC = \
contents.md \
$(wildcard intermediate/regex/*.md) \
$(wildcard intermediate/python/*.md) \
$(wildcard intermediate/doit/*.md) \
$(wildcard slides/*.html) \
Expand Down
12 changes: 12 additions & 0 deletions data/evil/notebook-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Site Date Evil (milliVaders)
Baker 1 2009-11-17 1223.0
Baker 1 2010-06-24 1122.7
Baker 2 2009-07-24 2819.0
Baker 2 2010-08-25 2971.6
Baker 1 2011-01-05 1410.0
Baker 2 2010-09-04 4671.6
Baker 2 2012-02-25 1099.0
Baker 1 2013-01-01 950.9
Baker 1 2012-07-23 2000.0
Baker 2 2013-08-22 3500.4
Baker 2 2014-01-02 4510.1
12 changes: 12 additions & 0 deletions data/evil/notebook-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Site/Date/Evil
Davison/May 23, 2010/1724.7
Pertwee/May 24, 2010/2103.8
Davison/June 19, 2010/1731.9
Davison/July 6, 2010/2010.7
Pertwee/Aug 4, 2010/1731.3
Pertwee/Sept 3, 2010/4981.0
Pertwee/June 20, 2011/2103.8
Davison/June 5, 2011/1731.9
Davison/Dec 14, 2011/2200.4
Pertwee/Nov 2, 2011/930.1
Pertwee/Sept 5, 2011/5000.9
11 changes: 5 additions & 6 deletions intermediate/regex/01-intro-regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ title: Introduction to Regular Expressions
A couple of years after the Death Star exploded, a hot-shot reporter at
the Daily Planet heard that children in the Shire were starting to act
strangely. Our supervisor sent some grad students off to find out what
was going on. Things didn't go so well for them, but their notebooks
were recovered and later transcribed.
was going on. Every student's notebook containing measurements of background evil levels (in milliVaders)
at various locations in the Shire was later transcribed and stored as a data file.

Our job is to read 20 or 30 files, each of which contains several
Our job is to read 20 or 30 of these data files, each of which contains several
hundred measurements of background evil levels, and convert them into a
uniform format for further processing. Each of the readings has the name
of the site where the reading was taken, the date the reading was taken
on, and of course the background evil level in millivaders. The problem
on, and of course the background evil level in milliVaders. The problem
is, these files are formatted in different ways. Here is the first one:


![image](img/01-intro-notebook-1.png)

A single tab character divides the fields in each row into columns. The
Expand Down Expand Up @@ -53,7 +52,7 @@ year-month-day.

We could parse these files using basic string operations, but it would
be difficult. A better approach is to use [regular
expressions](glossary.html#regular-expression). A regular expression is
expressions](../../gloss.html#regular-expression). A regular expression is
just a pattern that can match a string. They are actually very common:
when we say `*.txt` to a computer, we mean, "Match all of the filenames
that end in `.txt`." The `*` is a regular expression: it matches any
Expand Down
Loading

0 comments on commit d8429f7

Please sign in to comment.