I have the following code:
text = text.replace(/<[^>]*>/gi,'');
Which I believe should strip any HTML formatting from a string. Can any one adapt this to strip everything but line breaks (<br>).
Help appreciated.
DJ
Printable View
I have the following code:
text = text.replace(/<[^>]*>/gi,'');
Which I believe should strip any HTML formatting from a string. Can any one adapt this to strip everything but line breaks (<br>).
Help appreciated.
DJ
You don't really need to adapt it, just alter your <br> before using that line, and then change your <br> back. Here is how I would go about it.
1. Change every <br> to |br|(or something similiar to |br|)
2. Use: text = text.replace(/<[^>]*>/gi,'');
3. Change all |br| back to <br>
Then you would have removed all the syntax except for all of the <br>