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

296
Views
How can I get a specific word between HTML tags with Regex

Given this HTML string:

<p class="">What a <span>classy</span> man!</p>
<p class="tag">He has so much class.</p>

I'd like to use Regex to get the two instances of 'class' that are between the HTML tags (i.e. not the class attributes). Note, the word 'class' could be another word but the results must not include anything from inside the HTML tags.

I have this so far: /(?<=\>)(.*?)(?=\<)/gi which gets all text between the tags but how do I change this to look for a specific word instead?

Ultimately, my aim is to wrap instances of 'class' with a <mark> tag. i.e. I need Regex so that I can change the string to look like this:

What a classy man!

for the first line and like this: He has so much class.

for the second line.

Thanks

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!