Question:
I have the following string with many "spaces" (which are not spaces):
var cadena = "60 C"
Those spaces are not really spaces, they are null characters, their value in ASCII
is the number 0 (zero), I can't find a way to substitute those null characters for anything using the JavaScript
replace
function.
Can someone give me an orientation? Doing this doesn't work as spaces are not spaces, they are null characters.
cadena.replace(" ", "");
Answer:
You can use a regular expression , specifically \s
\s
: Matches a single whitespace character, including space, tab, form feed, line feed, and other unicode spaces.
Example:
var cadena = "60 C"
console.log(cadena.replace(/\s/g, ''));