Approximate overview
Events
Other good things
Is there a way to combine ranges with Rex’s?
Yes.
(rex-any-of (rex-char-range #\a #\z) (rex-char-range #\A #\Z))
Regular expressions give you a somewhat different way of thinking about computation. It’s “match this pattern” rather than “Here’s how we match that pattern.”
If you finish lab early, work on the third mini-project. You may work separately or together.
“Not alphabetic” is a bit complicated. rex-char-antiset is the
right intuition. But you should only do one call to rex-char-antiset.
Why? Consider the following.
(rex-any-of (rex-char-antiset "a") (rex-char-antiset "b"))
Does that match the string "a"? Yes! Why? Because although
(rex-char-antiset "a") doesn’t match, (rex-char-antiset "b")
does.
And yes, that means you probably have to write something like
(rex-char-antiset "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
Blame the people who designed the Rex library. Whoops, that’s me.
I’ve seen the following a few times.
(define whitespace
(rex-any-of (rex-string (string #\space))
(rex-string (string #\newline))
(rex-string (string #\tab))))
(define whitespace-sequence
(rex-repeat (rex-any-of (rex-string (string #\space))
(rex-string (string #\newline))
(rex-string (string #\tab)))))
Why don’t I like that definition of whitespace-sequence?
Consider the following …
(define book-characters (file->chars "pg1260.txt"))
(define first-20-characters (take (file->chars "pg1260.txt") 20))
Why don’t I like that?