Wouldn't a regex be simpler here?