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

103
Views
Regex replace words which are not inside anchor tags

I'm trying to find a regex that finds all words that are not within anchor tags. I already have a variant that works quite well, but unfortunately it doesn't work if the tags are nested.

Here is my expression:

(.*?)(\bFoobar\b(?!([^<>]*[^<>]*|[^<>]*)(<\/a|>)))(.*$)

This works, it finds Foobar:

<strong>Foobar</strong> bar baz

This works as well, it does not find Foobar, cause its inside anchor tag:

<a href="foobar.com">Foobar</a> bar baz

But this does not work, it finds Foobar:

<a href="foobar.com"><strong>Foobar</strong></a> bar baz

Thanks for your help.

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