response1 = CustomHttpClient.executeHttpPost("http://gamesdsxd.com/appfiles/login.php", postParameters);
String res = response1.toString();
res = res.replaceAll("\\s+", "");
我在想什么\ s +做什么,这个replaceAll做什么以及为什么需要它。这个java行是做什么的?
response1 = CustomHttpClient.executeHttpPost("http://gamesdsxd.com/appfiles/login.php", postParameters);
String res = response1.toString();
res = res.replaceAll("\\s+", "");
我在想什么\ s +做什么,这个replaceAll做什么以及为什么需要它。这个java行是做什么的?
该\s+
将替换所有发生的空间" "
没有空间""
。
如需更多帮助,请点击此链接:Removing Whitespace Between String.
请注意'\ s'不仅仅匹配普通的空格字符。例如,它也匹配制表符。 –
@Stuart我不知道,谢谢你的提示。 –
\ S +是一个正则表达式。它匹配由至少一个空格字符组成的字符串。 \ s其实是一个元字符。这里是删除空白。
这里是replaceAll文档。
的replaceAll(字符串的正则表达式,字符串替换) 替换此字符串与给定替换
这里是的replaceAll将一个小例子做给定的正则表达式匹配的每个子,
String str = "This5is5testing5of5replaceAll";
str = str.replaceAll("5", " ");
System.out.println(str);
这里的输出将是 - This is testing of replaceAll
5将被空间替换。
希望它可以帮助你知道什么是replaceAll。 谢谢
它将双空格或更多替换为无空格。例如:“”将转换为“”; “”将变成“”;但“”仍然等于“”。
只需单击您通过javadoc的方式:http://download.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang。 String%29 – BalusC
http://stackoverflow.com/questions/5429330/how-to-send-data-from-java-servlet-to-android-client –