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

167
Views
Cómo eliminar varias subcadenas de dos etiquetas

Dada una cadena así formada:

 hello Rose <tag> Micheal </tag> and <tag> July </tag> John.

Quiero eliminar todo entre <tag> y </tag> y tener en la salida:

 hello Rose and John.

como puedo

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Supongo que puedes usar:

 $new_html = preg_replace('%<tag>.*?</tag> ?%si', '', $old_html);
about 4 years ago · Santiago Trujillo Report

0

Si no desea usar DOM , siempre puede usar preg_replace para hacer esto.

 $content = 'hello Rose <tag> Micheal </tag> and <tag> July </tag> John.'; $content = preg_replace('/<tag>[^<]+<\/tag>/i', '', $content); print $content; // returns: hello Rose and John.
about 4 years ago · Santiago Trujillo 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!