0
我已经作为的htmlText删除空行中的htmlText为textarea的
<p>Here is what some pupils told me about how they prepared for and fared in yesterday's preliminary round.</p>
<hr />
<p>"I will stay calm and try my best. If I do not know a word, I will just have to put something down."</p>
<p><strong>some text</strong></p>
<hr />
<p>"I am more confident than last year because I have experience. I read the newspaper and I looked through the dictionary for difficult words and tagged them."</p>
<p><strong>some text</strong></p>
<hr />
我显示一样textarea.htmlText。
但textarea显示上面有太多空行在它们之间。有没有一种方法可以删除文本中的换行符?文本正在从服务器端来。
如何试图替换与空字符串的换行符像这样:'的htmlText = htmlText.replace(?/ \ r \ N/G, “”);' – 2013-03-11 09:00:58
这是要除去每一次换行,我至少需要一个换行符,但是如果有更多的换行符需要删除它们。 – sharmacal 2013-03-11 10:09:44
好吧,然后将上面的正则表达式改为这个'/ \ r?\ n {2,}/g'。这将只消除两个或更多的模式发生。 – 2013-03-11 10:41:57