Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda