比如有很多电话号码,然后其中一串电话号码带括号备注,如13412341234(测试),此时我们只想要数字,我们需要做的是两步:
遍历这组电话号码然后找出包含有左括号的然后截取到左括号为止的数字:
var phone = "13412341234(测试)";
boolean a = phone.contains("(");
if(a==true){
phone = phone.substring(0,phone.indexOf("("));
}
out.print(phone);