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

247
Views
JS, ¿cómo puedo eliminar texto en condiciones de comenzar en < y terminar en >?

Tengo un documento html de texto y me gustaría eliminar todo el código html y dejar todo el texto sin formato.

 <p>Random text generated by some method</p> <p style="text-align:center;">centered text example</p> <p>Full name</p> <p>IRSP</p>

la salida debe ser:

 Random text generated by some method centered text example Full name IRSP

Soy un poco nuevo, así que cualquier documento relacionado con esto es bienvenido.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar un DOMParser para analizar la cadena y obtener el contenido de textContent del resultado:

 const str = `<p>Random text generated by some method</p> <p style="text-align:center;">centered text example</p> <p>Full name</p> <p>IRSP</p>` const res = new DOMParser().parseFromString(str, 'text/html').body.textContent; console.log(res)

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!