Search code examples
javascriptnode.jsdiscorddiscord.js

Removing what I assume is static from text


I'm using discord.py to make a decent censoring program, and so far it works pretty well. That is, until someone started using different languages and fonts (Like "ḟ̸͐ă̵̓ǵ̸̐g̶͛̚o̷̾͝ẗ̴̛", for example). It has bypassed everything I've tried, including passing it through Google Translate. How can I convert that into a normal string using JavaScript?


Solution

  • For English, one very basic method would be to strip out non-word characters and then look at the result to see if it needs to be censored:

    const textToTest = input.replace(/\W/g, '')
    

    This successfully de-zalgos the string in your question.