Ad
Strings
Strings
Strings
Code
Diff
  • //hacer que no funcione con una expresion regular con el caracter fin de cadena
    
    public class ConfusedDouble {
      
       public static String clearDouble(String str) {
    		if (str == null || str.length() == 0 || str.matches("^[^.]*$")){
          return ""; 
        } 
    		double num = Double.parseDouble(str.replaceAll("[^0-9.]", ""));
        String result = Double.toString(num);
        return result;
    	}
      
    }
     
Strings
Strings
Strings
Code
Diff
  • //hacer que no funcione con una expresion regular con el caracter fin de cadena
    
    public class ConfusedDouble {
      
       public static String clearDouble(String str) {
    		if (str == null || str.length() == 0){
          return ""; 
        } 
    		double num = Double.parseDouble(str.replaceAll("[^0-9.]", ""));
        String result = Double.toString(num);
        return result;
    	}
      
    }
     
    • //hacer que no funcione con una expresion regular con el caracter fin de cadena
    • public class ConfusedDouble {
    • public static double clearDouble(String str) {
    • if (str == null || str.length() == 0) return 0;
    • return Double.parseDouble(str.replaceAll("[^0-9.]", ""));
    • public static String clearDouble(String str) {
    • if (str == null || str.length() == 0){
    • return "";
    • }
    • double num = Double.parseDouble(str.replaceAll("[^0-9.]", ""));
    • String result = Double.toString(num);
    • return result;
    • }
    • }
Strings
Code
Diff
  • //hacer que no funcione con una expresion regular con el caracter fin de cadena
    
    public class ConfusedDouble {
      
       public static double clearDouble(String str) {
    		if (str == null || str.length() == 0) return 0; 
    		return Double.parseDouble(str.replaceAll("[^0-9.]", ""));
    	}
      
    }
     
    • //hacer que no funcione con una expresion regular con el caracter fin de cadena
    • public class Solution {
    • public class ConfusedDouble {
    • public static double clearDouble(String str) {
    • if (str == null || str.length() == 0) return 0;
    • return Double.parseDouble(str.replaceAll("[^0-9.]", ""));
    • }
    • }