Well, it's probably not a good idea to offend Cthuhlu, so we actually want to match every line that does not have vowels. Normally that would involve you writing out all of the characters that don't match, which is tedious and dumb. Instead, you can invert the set by putting a ^ (caret) as the first character inside the set.


To make this work I have to switch to !match mode, which will actually match the first character. I also have to use a more complete "vowels" set since I didn't have capital letters in the previous exercise. Once you have that, put the ^ at the front and it will now be an inverse set.

What You Should See

When you run this it should only print the thing Cthuhlu said:

That file doesn't exist.
> !match
Match mode: match
> [^aeiouyAEIOUY]
Input file is empty. Use !load to load something.

There's something else you might have missed in the last exercise. The above character set is matching one character, but you can make a regex that is two sets and it will match one, then the next. You could do [a-z][A-Z][0-9] and that would match, "A lowercase letter followed by an uppercase letter followed by a number."

Extra Credit

  • Create another class that is "everything except X" so that it doesn't match Cthulhu's line.
  • Go back and update your phone number matching regex so that it's "not letters" instead.

Portability Notes

Some regex engines don't have this feature. Those regex engines suck since it's a trivial thing to implement and is a commonly needed operation.