问问题
195 次
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
Use String#replaceAll(regex, str)
String company = "PRIVATE Basit PTE";
System.out.println(company.replaceAll("PTE|LTD|PRIVATE|LIMITED", ""));
output:
Basit
于 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","");
will result in
BasitMasood
于 2013-03-07T08:14:21.050 回答