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

198
Views
regex, replace all matches but once

let me explain my problem, i have this code so far:

post.contentHtml().replace(/<\/?[^>]+(>|$)/g, '📷')

that strip ALL html tag from the output and replace with '📷'.

Now the problem is that a post can contain multiple tag, so if someone post an image or embed like:

<p><iframe data-s9e-mediaembed="twitter" allow="au…t:250px;max-width:550px;width:100%"></iframe></p>

the result is this: 📷📷📷📷📷

what i'm want to achieve is to show only ONE icon per element, or simply 1 icon. Is that possible

post.contentHtml output is:

ContentHtml: '<p><iframe data-s9e-mediaembed="twitter" allow="au…t:250px;max-width:550px;width:100%"></iframe></p>'
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Quantify the regular expression so it will match multiple times in a row.

post.contentHtml().replace(/(<\/?[^>]+(>|$))+/g, '📷')

pattern+ matches a sequence of 1 or more matches of pattern

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!