开发者

remove line breaks and white spaces [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

Replace Line Breaks in a String C#

hi I have an textarea which anyone can enter text, where they can put line breaks inside the text area.

How can I remove the line breaks created by press开发者_开发问答ing the enter key? can either be in c# or javascript.


Try,

text.replace(/\s*/g," ")

This will collapse all contigious whitespace into a single space.


an alternative is to simply ban the use of the enter key in the textarea in the first place, which can be done with event handlers (onKeyPress, for example)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜