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

103
Vistas
how to safely truncate text containing html tags with javascript

I have a string like this:

Hello world!<br />this is a new day for us<br /><br />lorem ipsum dolor and more long string here

and I need to only show the first 15 characters.. how do I do that? if possible I want to use only vanilla js (no jquery)

I thought of these steps:

  1. get rid of the html tags

  2. use substr to truncate the string

but some people says that using regex myString.replace(/<[^>]*>?/gm, ''); in javascript to strip html tags is not 100% dependable.. (link here) so now I don't know what to do. any help is appreciated

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