Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda