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

211
Vistas
How do I remove the characters in a string that are included in another string

How do I remove the characters in a string that are included in another string?

let mustRemoved = "rin8cu73s9b";
let string = "CatsAndDogsAreAwesome"

Output Must Be : atAdDogAeAweome

What I have tried:

let regEx = new RegExp(mustRemoved, "ig");
let replaceMask = "";
let final = string.replace(regEx, replaceMask);
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can convert the string into an array of characters, filter out the characters which are included in mustRemoved, then join the resulting array.

let mustRemoved = "rin8cu73s9b".toLowerCase();
let string = "CatsAndDogsAreAwesome"

let res = [...string].filter(e => !mustRemoved.includes(e.toLowerCase())).join('')
console.log(res)

about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to change your regex so that it matches with every character in mustRemoved string, like this:

let mustRemoved = "rin8cu73s9b";
let string = "CatsAndDogsAreAwesome"
let regEx = new RegExp(mustRemoved.split('').join('|'), "ig");
let replaceMask = "";
let final = string.replace(regEx, replaceMask);
console.log(final)

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