Use the replace() method to return a new string with a substring replaced by a new one. · Use a regular expression with the global flag ( g ) to replace all ... ... <看更多>
Try this: String r = t.replaceAll('[^0-9]','');. Explanation: Instead of hunting for invalid characters and removing them explicitly you can ... ... <看更多>