&の前後にある空白を削除するにはどうすればよいですか?
http://chemist.com:8080/eShop/search_results.jsp?IDNUMBER=BB55-7344&Source = BuildingBlocks
&の前後にある空白を削除するにはどうすればよいですか?
http://chemist.com:8080/eShop/search_results.jsp?IDNUMBER=BB55-7344&Source = BuildingBlocks
試す :
urlString = urlString.replaceAll(" ", "%20");
このコードはすべての空白を置き換えます。
String newUrl = oldUrl.replaceAll(" ", "");
お役に立てれば。
試す:
String newURI = oldURI.replaceAll("\\s+", "");
if(result.contains(" and "){
resultnew = result.replace(" and ","&").toString();
}
"if" チェックは実際には必要ありませんが、" and " が見つからない場合に replace() が入力文字列を返すため、より高速です (結果に常に" and " が含まれない限り)。replace() は文字列を返すため、toString() も必要ありません。