Text this: Regulated rewriting in formal language theory