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

230
Vistas
Slipt a text with accents passing by argument a text without accents

I'm trying to highlight a text following this code:

function getHighlightedText(text, highlight) {
  var parts = text.split(new RegExp(`(${highlight})`, 'gi'));
  return parts.map((part, index) => (
    <React.Fragment key={index}>
      {part.toLowerCase() === highlight.toLowerCase() ? <b style={{ backgroundColor: '#e8bb49' }}>{part}</b> : part}
    </React.Fragment>
  ));
}

When I pass as arguments a text with accents and highlight without, I can't get the right return as I want

Exemple 01: getHighlightedText("Avô","avo")
Expected 01: (hightlighted) Avô
Returned 01: nothing

Exemple 02: getHighlightedText("Coração","cao")
Expected 02: (Not Hightlight) Cora (hightlighted) ção
Returned 02: nothing

The problem is when I try to split a text with accents with another there aren't accents my return is unexpected.

Question: Is there any way to put some rule in split to handle this case?
I'm trying to avoid handle with it go through all both string (e.g using For)

about 4 years ago · Juan Pablo Isaza
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