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

180
Vistas
Remove/ Replace span of Specific String from the sentence

I am trying to remove the span tag from string of sentence .Is it possible .?

My Input is as below :

divData = Welcome Hello <span> World </Span> ! Looking forward the great <span>things</span>.

Output I am looking for :

divData = Welcome Hello World ! Looking forward the great <span>things</span>.

what I have tried is :

  str = divData.replace(/<\/?span[^>]*>/g,"");

But above one is replacing all the span of all sentence.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try this,

str = divData.replace(/<span[^>]*>/,"");
str = str.replace(/<\/?Span[^>]*>/,"");

(Removed 'g' flag) 'g' means global, it will replace everything in the string.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You may use replace here in non global mode, which will target the first span tag only:

divData = "Welcome Hello <span> World </span> ! Looking forward the great <span>things</span>.";
divData = divData.replace(/<span>\s*(.*?)\s*<\/span>/, "$1");
console.log(divData);

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