Used regexes to simplify handling of whitespace and comments