I have some legacy code which uses "[[:punct:]]+" in a regular expression replace (using PHP's ereg_replace) to remove all punctuation chars.
Eg: ereg_replace('[[:punct:]]+', 'test1-2,3.4:5', '') returns 'test12345'
What I want to do is remove all punctuation except "-", ie to get the result "test1-2345".
I can't currently think of a regex that will do it, other than [^.,:]+ where I list all punctuation except - between the square brackets, but that would be a nightmare to create and maintain.
Is there a way to invert [:punct:] somehow so that [^-[:inverted-punct:]]+ would work?