Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
How remove multiple substring from two tags

Gived a string so formed:

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

I want remove all between <tag> and </tag> and to have in output:

hello Rose and John. 

how i can it?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I guess you can use:

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

0

If you do not want to use DOM, you could always use preg_replace to do this.

$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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda