如何修剪字符串中的"输入键"

Lea*_*ner 0 java jsp

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

Sna*_*ake 6

String strFCKeditor1 = request.getParameter("FCKeditor1").replaceAll("\\r|\\n", "");
Run Code Online (Sandbox Code Playgroud)

您还需要替换\r和/或\n\r(因此正则表达式),而不是\n像其他答案中所述,因为您不知道您的用户是否使用Windows/Mac OSX/Linux.