-3

I have text like this :

<div id="content">
    Com mitius gementibus vivamus ultrices acervis te; Ultimo massapellentesque conspiratione diaminteger antiochiae; Stirpis suadendo, perpensum malesuada nal
    ↚
    fusce Se actibus curae. Mus consectetur paulatim mors ca or purusvestibulum litora,
    ↚
    Repentina venenatis! Conpluribus enimsed Mitius saevientis legum infudere ubi:
    ↚
    Sur quoque commodo tin cum Clematius ra, animis! Varietas dira ad quis nebulas invitis facti tempestates the: Paulatim agebantur Malesuadanullam vero lectus dictumst domus.
</div>

how can I remove all symbols from text with Javascript

Nanoo
  • 836
  • 8
  • 16
jimi-del
  • 93
  • 1
  • 11
  • 1
    `'your-content'.replaceAll('your-character', '')` I'm guessing this would work? – halilcakar Jun 27 '20 at 00:06
  • 1
    You can use the .replace(regx,' ') -> https://stackoverflow.com/questions/150033/regular-expression-to-match-non-ascii-characters – Carlos1232 Jun 27 '20 at 00:10
  • We need an actual runnable example of something that doesn't work to address your problem. There isn't anything immediately clear in your example text of something that doesn't work with a simple replace. – user120242 Jun 27 '20 at 00:42
  • `content.innerText=content.innerText.replace(/↚ /g,"")` – iAmOren Jun 27 '20 at 00:43
  • @HalilÇakar `replaceAll` is available on Chrome (I don't care about other "browsers") from 85. Mine is at 83. I'm sure you knew that. It would have been nice to mention that... – iAmOren Jun 27 '20 at 00:50
  • Yea if needed then regex is the best solution i'm guessing :) – halilcakar Jun 27 '20 at 00:51
  • Personally, I prefer regex - because with `replace(/text/g, "")` you can't use variables or functions. – Nanoo Jun 27 '20 at 01:57

1 Answers1

0

Try this:

var elementText = document.getElementById("content");
elementText.innerHTML = elementText.innerHTML.replace(new RegExp("↚", "g"), "");

This will replace all of the with an empty string (essentially removing them).

I'm not quite sure where those strange characters came from though - the slash isn't even a default keyboard slash. Any clue why it could have occurred?

Nanoo
  • 836
  • 8
  • 16