Learner
Learner

Reputation: 345

how to trim "enter key" in a string

String strFCKeditor1 = request.getParameter("FCKeditor1");

Upvotes: 0

Views: 14293

Answers (3)

Anemoia
Anemoia

Reputation: 8116

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.

Upvotes: 6

Pushkar
Pushkar

Reputation: 7580

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

Upvotes: -2

Jigar Joshi
Jigar Joshi

Reputation: 240870

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

Upvotes: 1

Related Questions