Reputation: 395
I am getting the content of a div using getElementById
function, but inside the div there are some text formatting like font, p, b ...
, so when i use myvar.textContent
, i do get all the text but not exactly the way i need it ... I mean, instead of getting something like paragraphs, i get the lines separated :
*************************************
*************************************
*************.
I get :
******
***************
***********************
is there a way in javascript to remove the \r\n and still make a difference between two paragraphs, knowing that between two paragraphs there are 3 to 4 \r\n?
Thanks in advance.
EDIT :
What i am trying to do is to read body of an email in Gmail
what should look like :
*Dans la perspective de consolider sa relation avec les lauréats et étudiants, eHECT vous propose deparrainer un membre de votre famille souhaitant poursuivre ses études au sein de notre établissement.
Pour plus de détail et inscription allez sur ...*
I do get
Dans la perspective de consolider sa relation
avec les lauréats et étudiants,
eHECT vous propose deparrainer un membre de votre
famille souhaitant poursuivre ses études au sein de notre établissement.
Pour plus de détail et inscription allez sur ...
Upvotes: 0
Views: 396
Reputation: 135782
Try the following regex:
/\r?\n((?!\r?\n)|(?=\r?\n\r?\n\r?\n))/g
JavaScript demo here (check the console).
Upvotes: 1
Reputation: 373
If you want to get clear text divided into paragraphs, you need to get content with html tags (this is only way to reach information about paragraphs) and then remove unwanted tags like <b>
, <font>
.
Upvotes: 1