Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
¿Cómo elimino los caracteres en una cadena que están incluidos en otra cadena?

¿Cómo elimino los caracteres en una cadena que están incluidos en otra cadena?

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

La salida debe ser: atAdDogAeAweome

Lo que he probado:

 let regEx = new RegExp(mustRemoved, "ig"); let replaceMask = ""; let final = string.replace(regEx, replaceMask);
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede convertir la cadena en una matriz de caracteres, filtrar los caracteres que se incluyen en mustRemoved y luego unirse a la matriz resultante.

 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 Report

0

Debe cambiar su expresión regular para que coincida con cada carácter en la cadena mustRemoved , así:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!