You can make use of the ^. It considers everything apart from what you have infront of it.
So if you have [^y] its going to filter everything apart from y. In your case you would do something like
String value = string.replaceAll("[^0-9]","");
where string is a variable holding the actual text!