made the regex library more robust to malformed input