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

186
Visualizações
How to match a word with no special character at front and back

I am trying to match a word which has no special characters attached at both front and back. The regex I have written is /\btest\b/gi I have added two word boundaries at front and back for matching the exact word. The sample text is :

This is a test.
The testing was good.
The tester was bad.
package.test.com
skkg@test.com
Regex-test-is tough
"rm/_HOST@DEV.HADOOP.R1-CORE.R1.TEST.NET&quot
/Users/dattem/Desktop/DevCenter/test/ssl/
The test is today.
Name -test one

I want to match the test word of only first and last two lines. https://regex101.com/r/AEfzUw/4

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

0

The following regex will match only the first and last 2 lines in your cases:

(?<=[\s\t-])test(?=[\s\.\t])

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

It uses positive lookbehind and lookahead:

  • (?<=[\s\t-]) a space, tab or dash
  • test test
  • (?=[\s\.\t]) followed by a space, a dot or tab
about 4 years ago · Juan Pablo Isaza Relatório

0

This does the trick:

(?<= )test\b|\btest(?= )

The word test either preceded or followed by a space. I don't think there is a way to avoid repeating the word test in the regex.

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