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

94
Visualizações
How to find substring ignoring the data inside comment

I am trying to find substring from an HTML string by ignoring the commented code. I have tried something like below but it is nor giving me expected result , Any pointer will be really appreciated.

let a = `<div data-bind="attr: {id: componentId + 'MasterDetailContainer'}"
     style="height: 100%; width: 100%">

    <!-- master --> <!-- Bug 31793483 adding aria label -->
    <div role="navigation" data-bind="attr: {id: componentId + 'MasterDetailStartDrawer'}">`;
 
let databindIndex =a.indexOf('data-bind');
//Get all the data till next valid starting tag ignoring commented code
let data =a.indexOf(/<\w\s/g,databindIndex);
console.log(data);

Expected output

`data-bind="attr: {id: componentId + 'MasterDetailContainer'}"
         style="height: 100%; width: 100%">
    
        <!-- master --> <!-- Bug 31793483 adding aria label -->`
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use something like this:

const text = `<div data-bind="attr: {id: componentId + 'MasterDetailContainer'}"
     style="height: 100%; width: 100%">

    <!-- master --> <!-- Bug 31793483 adding aria label -->
    <div role="navigation" data-bind="attr: {id: componentId + 'MasterDetailStartDrawer'}">`

const pattern = /data-bind[^\>]*>[\s\S]*<!--[\s\S]*?-->/

const result = text.match(pattern)

console.log({result})

about 4 years ago · Santiago Trujillo 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