improved regex parser