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

187
Vistas
Highlight a word in a row of a table in Reactjs

I have an row object say user which contains key value pair of column and value of that column. Now i want to highlight all the occurrences of a particular word in that row and then return that updated row.Reactjs table

I was trying something like this but it didn't work

const searched = searchVal;
if (searched !== "") {

            Object.entries(user).forEach(([key, value]) => {
    if (value.includes(searched))
    {
            
            const re = new RegExp(searched, "g");
            const newText = value.replace(re, `<mark>${searched}</mark>`);
            value = newText;
          
          }
          return origData[index];
        }

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

0

Something like this

const searched = 'jo'


const user = {
 name: "john",
 lastname: "doe"

}

const highlight = (obj, search) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, value.replace(new RegExp(search, 'ig'), `<mark>${search}</mark>`)]))


console.log(highlight(user, 'jo'))

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