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

174
Visualizações
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
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