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

173
Views
While replacing the text in red with other text , the replaced text should be in black in react

While replacing the red colored text which surrounded with square brackets of red color.The replaced text should be in black but it turns out be red. How do I fix this

The below code checks for the word with square brackets and if there are, replace those with red color in a textbox(textbox implemented using contenteditable)

if we want to replace those red colored words with other data in a textbox , then while updating it should be in black. If I go one space before of that square bracket word and try to enter something then only it will be in black otherwise it will be in red

  if (event.match(/([^[]+(?=]))/g)) {
  {
  var newTxt = event.split('[');
  let sampleText = event;
  for (var i = 1; i < newTxt.length; i++) {
    let value = newTxt[i].split(']')[0];
    console.log(value, "matchhh");

    sampleText = this.replacecanned(sampleText, `[${value}]`, `<span style="background: yellow;">[${value}]</span>`);

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