Is it possible to use regex character class subtraction in some way in GNU sed, GNU awk, GNU grep, or anywhere else from bash?
Is it supported in C++11?
Where this feature is supported? I was unable to find any references except this one: http://msdn.microsoft.com/en-us/library/20bw873z.aspx (at the bottom).
To be more specific: what’s the best way to convert all the digits except 2 and 5 to asterisks, something like
sed -re 's/[0-9-[25]]/*/g'
No, not with those tools/regex-implementations.
Most (popular) languages do not support this. Java has a way to do this:
[0-9&&[^25]](matching any (ASCII) digit except'2'and'5'), but I know of no other implementations that support this.Either use negative look-ahead
(?![25])[0-9], as Ignacio already suggested, or do it “the hard way”:[1346-9]See: