Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!