CORGI: Efficient Pattern Matching With Quadratic Guarantees