Regex and syntax fixes in text parser