Fix regexp error when scanning to eos