Refactored to be stateless. Now uses regexp pattern matching.
Added frozen string test.