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

103
Visualizações
Find specific word between tag start and end

I need to find a word this within <template> and </template>:

I tried <template>([this])*?<\/template> but it doesn't seem to work.

https://regex101.com/r/VmGESa/1

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You do not need the multiline m flag and . doesn't match linebreaks so you have to account for that.

E.g.

<template>(?:.|\r|\n)*?(this)(?:.|\r|\n)*?<\/template>

https://regex101.com/r/krkP9d/1

about 4 years ago · Juan Pablo Isaza Relatório

0

Your regular expression is matching strings that

  • are starting with <template>,
  • followed by an arbitrary combination of the characters t, h, i or s with arbitrary length, e.g., thssiththissiththhtht would be matched by ([this])*,
  • are ending with </template>,

Does this solution work for you?

<template>(?:.|\n|\r)*(this)(?:.|\n|\r)*<\/template>

.* matches an arbitrary number of arbitrary characters, except for new lines. So, I added \n and \r with the OR operator |. (?:...) means, it's a non-capturing group, i.e., when asking for groups, this group won't show up.

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