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

184
Views
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 answers
Answer question

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 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!