I don't think it is so much the tilde(~)being at the end but the hyphen (-) not being on one of the ends. That is, if the hyphen is not at either end of the character class then it becomes a range for whatever two chars it is in between.This should work the same as all the others for instance: