Start up Regetron again and type this in:

!data "The lazy dog\nsleeps in the yard."

Enter each of these lines as commands to regetron, and make sure you get them right.

What You Should See

Compare what you get for output with what I have below and make sure it's the same.

That file doesn't exist.
> !data "The lazy dog\nsleeps in the yard."
> .*lazy.*
0000: The lazy dog
> [A-Z][a-z]*
0000: The lazy dog
> [a-z]\.
0001: sleeps in the yard.

I've skipped showing you my entire shell session for starting Regetron here, and won't show it unless it matters to the exercise. Just assume that I started Regetron and entered this text in at the ``> `` prompts, then it printed the response under it.

System Message: WARNING/2 (ex1.rst, line 43); backlink

Inline literal start-string without end-string.

What Regetron does is take what you type, convert it to a regular expression, and then runs that regular expression on each line. In the above we set the data to these two lines:

The lazy dog
sleeps in the yard.

If a regular expression matches a line, then it gets printed. In the above you can see the first line gets matched twice, and the second only by the last regular expression.

Extra Credit

  • Try entering a word that is not in either of the lines so you can see that Regetron prints nothing. Like "pizza". Doesn't matter what it is.
  • Give regetron a file of text with regetron myfile.txt and then try these same expressions to see what you get. Make sure you do not enter the first !data command.
  • Do the same thing with the !load command.
  • Flip "match" mode on with !match and try these expressions again. Can you explain what's going on?
  • If you know Python, go read Regetron's code. It's pretty small.