Not to nitpick, but [0-9] is \d and [^0-9] is \D .

And in this specific case, the S switch isn't necessary since all control codes would be considered "not digits" anyway.

-genius_at_work