Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
How to select and replace certain words in input strings regardless of the full string. (More info for clarification below)

I am making a filter for a chat room I own.
I was succesful in having it turn NSFW words into a bunch of symbols and astericks to censor it, but many people bypass it by simply putting a backslash, period, or other symbol/letter after it because I only put in the words without the punctation and symbols. They also come up with a bit more creative methods such as eeeNSFWeee so the filter doesn't count it as a word.
Is there a way to make it so that the filter will select certain characters that form a word in a string and replace them (with or without replacing the extra characters connected to the message)?

The Filter is made in javascript and Socket.io

Filter code:

    const array = [
  "NSFW",
  "Bad Word"
  "Innapropiate Word"
];

message = message
  .split(" ")
  .map((word) => (array.includes(word.toLowerCase()) ? "$#!%" : word))
  .join(" ");

For an example if somebody typed "Bad Word" exactly like that (caps are not a problem), it would censor it succesfully.
But if somebody typed "Bad Word." that would be a problem because since it has a period it would count it as a different word, thats what I need fixed.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There are a number of approaches you could take here.

You could use replace() if you just want to remove symbols. For example:

word.replace(/[&\/\\#,+()$~%.`'"!;\^:*?<>{}_\[\]]/g, '')

You could use Regular Expressions in general, which allows you to match on patterns instead of exact string matching.

You could also use more complex fuzzy matching libraries or custom fuzzy matching to accomplish your goal. This post may be helpful.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda