3
4

4 に答える 4

1
String[] str = {"PTE", "LTD", "PRIVATE", "LIMITED"};
String company = "PTE      Basit PTE";
for(int i=0;i<str.length;i++) {
    company = company.replaceAll(str[i], "");
}
System.out.println(company.replaceAll("\\s","")); //remove whitespaces
于 2013-03-07T08:21:52.347 に答える
1

String#replaceAll(regex, str)を使用

    String company = "PRIVATE Basit PTE";
    System.out.println(company.replaceAll("PTE|LTD|PRIVATE|LIMITED", ""));

出力:

ベイシット

于 2013-03-07T08:21:58.620 に答える
0
String company = //your string
company.replaceAll("PTE|LTD|PRIVATE|LIMITED", "");
于 2013-03-07T08:14:49.493 に答える
-1

"PTEBasitLTDMasoodPRIVATE".replaceAll("PTE|LTD|PRIVATE|LIMITED","");

結果として

ベイシットマスード

于 2013-03-07T08:14:21.050 に答える