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

104
Views
Find word that does not come after word with RegEx

I'm trying to get all the text which start with @ and replace them with the needed text

here's it's regex

/@([a-z_\d]+)/gi

Now the issue I'm facing is I just wanted to get the text if it's alone like

example: hey @hasham my email is vakanihasham@gmail.com

When I run the regex, it should provide me with the @hasham value but not the @gmail. I tried a solution by addingin \s to check empty space before the matching parameter but the issue I'm having is that when the @hasham is first in the paragraph, it doesn't get it because there is no empty space before trying to find a way. How can I simply select the independent words that fit my regex?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use a negative lookbehind.

/(?<!\S)@(\w+)/g

This matches @ if it's not preceded by a non-whitespace character.

DEMO

about 4 years ago · Juan Pablo Isaza Report

0

You may use this regex with \B (reverse of word boundary):

/\B@(\w+)/g

Updated RegEx Demo

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!