A undecidability result for regular anguages and its applications to regulated rewriting