I can not delete all spaces in a string


Good morning,

I do not know if I'm doing something wrong. I just want to eliminate the spaces at each end of a string, for that I use .trim() . The code that I have:

String quedan = doc.select(".c-price .text-muted").first().text(); //save $1.40 • 6 days remaining            
String[] parts = quedan.split("•");
String remaining = parts[1];
String[] partes = remaining.split("day");
String dias_remaining = partes[0].trim().replace(" ", "");
dias_remaining = dias_remaining.trim(); //me devuelve: " 6" en vez de "6", con lo que no me deja pasarlo a int en el siguiente paso. 
int dias_remaining_int = Integer.parseInt(dias_remaining);

I do not see the space that is right in front of number 6 being a special character.

asked by JetLagFox 21.05.2017 в 11:20

1 answer


Finally I have solved it:

.replaceAll("\u00a0", "")

Apparently it was a special character.

answered by 21.05.2017 / 15:11