Better error messages on bad regexs

closes #1239