I was trying to debug a problem of searching inside a string and it came down to the following interesting piece of code.
Both "item "
and "item "
seem equal but they are not!
var result = ("item " === "item ");
document.write(result);
console.log(result);
After investigating this further by pasting it on a Python interpreter, I found out that the first "item "
has a different kind of space as "item\xc2\xa0"
. Which I think is a non breaking space.
Now, A possible solution to match these strings will be to replace \xc2\xa0
with space, but is there a better approach to convert all special space characters with normal space?.