Go to the Python re library documentation page and search for "special sequences". Python's re library is what I'm using in Regetron and it supports most of the standard special escape sequences found in other regex engines. These sequences can be thought of as "macros" for common things you do in regular expressions.

!data "\t\tI have spacing\t\t\nI have 12345 cheeses!"
\s+\w+ have \w+\s+
.*have\s\d*\s.*

This script uses the most useful special sequences to match spacing and "words": \s, \d, and \w. Go through this script and make sure you can identify each of the special sequences used and look up what they do.

What You Should See

When you run this script you should see each regex match its line as expected.

That file doesn't exist.
> !data "\t\tI have spacing\t\t\nI have 12345 cheeses!"
> \s+\w+ have \w+\s+
0000:            I have spacing
> .*have\s\d*\s.*
0001: I have 12345 cheeses!
>

Extra Credit

  • Rewrite these regex in verbose form and include the names for the special sequences used.
  • Come up with your own script that demonstrates the other special sequences.
  • Add the sequences you could get to work to your list of cards and start drilling them each night. To be honest, the only ones I know by heart are the ones I used in this exercise's script.

Portability Notes

Regex engines will typically come up with other escape sequences so you'll need to refer to your documentation if you're not using the Python re library.