Compiling regular patterns