Patched up regex matching bug. Included tests for it.