开发者

how to trim "enter key" in a string

String strFCKeditor1 = request.开发者_Python百科getParameter("FCKeditor1");


String strFCKeditor1 = request.getParameter("FCKeditor1").replaceAll("\\r|\\n", "");

You also need to replace the \r and/or \n\r (hence the regex), not just \n as stated in the other answer, since you don't know whether your user is using Windows / Mac OSX / Linux.


strFCKeditor1.replaceAll("\n","");//this will replace all \n with blank string


From your question i assume you want to remove the newline characters from the end of your string.

Use -

StringUtils.chomp(str);

http://commons.apache.org/lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.html#line.4353

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜