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

301
Visualizações
How can I get a specific word between HTML tags with Regex

Given this HTML string:

<p class="">What a <span>classy</span> man!</p>
<p class="tag">He has so much class.</p>

I'd like to use Regex to get the two instances of 'class' that are between the HTML tags (i.e. not the class attributes). Note, the word 'class' could be another word but the results must not include anything from inside the HTML tags.

I have this so far: /(?<=\>)(.*?)(?=\<)/gi which gets all text between the tags but how do I change this to look for a specific word instead?

Ultimately, my aim is to wrap instances of 'class' with a <mark> tag. i.e. I need Regex so that I can change the string to look like this:

What a classy man!

for the first line and like this: He has so much class.

for the second line.

Thanks

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