0

I have a french number: 1 138. The string is 1 138

I want to replace all the   with ''.

I do

alert(document.getElementById('gvdesglose_programas_ctl03_lblndescargas').innerHTML.replaceAll(/\&nbsp\;|\s/g,''))

But it doesn't change. I don't know why.

deceze
  • 510,633
  • 85
  • 743
  • 889
volar.2016
  • 13
  • 3
  • Could it be that your regex search is specifically looking for ` ` and the character within the search string is simply a `' '` whitespace character? See [this answer for more insight](https://stackoverflow.com/questions/1357078/whats-the-difference-between-nbsp-and) – Daniel Sep 05 '22 at 11:36
  • Does this answer your question? [Remove ' ' - still trying](https://stackoverflow.com/questions/6452731/remove-nbsp-still-trying) – Abdulla Nilam Sep 05 '22 at 12:06
  • Does this answer your question? [javascript regex replace html chars](https://stackoverflow.com/questions/1229518/javascript-regex-replace-html-chars) – Justinas Sep 05 '22 at 12:07
  • You try to replace literal chars sequence ` ` and not HTML entity ` `, that is actually one character – Justinas Sep 05 '22 at 12:08
  • BTW, there's not point using `replaceAll` if your doing `/g` regex. just saying. – vsync Sep 05 '22 at 12:11
  • `innerHTML` will return the replaced HTML entity not the original source - try `innerText` instead. – phuzi Sep 05 '22 at 12:19

0 Answers0