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

189
Views
¿Cómo convertir una cadena html en texto sin formato sin etiquetas html en el script de la aplicación de Google?

Soy nuevo en el script de la aplicación de Google.

Estaba tratando de convertir una cadena html en texto sin formato sin etiquetas html en el script de la aplicación de Google usando la referencia en esta pregunta.

Sin embargo, cuando trato de aplicarlo a mi script, no funciona como se esperaba.

Este es el script que uso:

 function toStringFromHtml(html) { html = '<div>' + html + '</div>'; html = html.replace(/<br>/g,""); var document = XmlService.parse(html); var strText = XmlService.getPrettyFormat().format(document); strText = strText.replace(/<[^>]*>/g,""); return strText; }

y esta es la salida: ingrese la descripción de la imagen aquí

Mientras que mi expectativa real está en la tercera columna.

¿Alguien puede decirme qué está mal con mi script anterior?

¡Gracias!

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

0

En su situación, por ejemplo, ¿qué tal la siguiente modificación?

De:

 return strText;

A:

 return strText.trim();

Referencia:

  • recortar()
about 4 years ago · Juan Pablo Isaza Report

0

Si está ejecutando en un navegador, entonces la forma más fácil es dejar que el navegador lo haga por usted.

 function stripHtml(html) { let tmp = document.createElement("DIV"); tmp.innerHTML = html; return tmp.textContent || tmp.innerText || ""; }
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!