-3
如何在s[0,2]
location(818001,818002)(151515,151515)
指定以下字符串中刪除","
並存儲再次串[]的Java String []數組去除特殊字符
String[] s = {"818001,818002","121212","151515,151515"};
如何在s[0,2]
location(818001,818002)(151515,151515)
指定以下字符串中刪除","
並存儲再次串[]的Java String []數組去除特殊字符
String[] s = {"818001,818002","121212","151515,151515"};
你應該解釋更詳細的您的問題。
我想你想要的是這樣的:
s = '(818001,818002)(151515,151515)' //the string you have.
s = s.replace(')(',',').replace('(','').replace(')','');// output "818001,818002,151515,151515"
final_string = s.split(','); //output (4) ["818001", "818002", "151515", "151515"]
如果您需要在您的字符串數組中刪除逗號(或其他任何字符爲此事)指數最簡單的是通過數組和使用迭代String.replace()
:
String[] s = {"818001,818002","121212","151515,151515"};
for(int i=0; i<s.length; i++) {
s[i] = s[i].replace(",", "");
}
System.out.print(Arrays.toString(s)); // [818001818002, 121212, 151515151515]