java 截取替换掉括号 包括括号中的内容


    public static void main(String[] args) {
        String company = "华厦世纪(厦门)地产";
//        System.out.println(str.indexOf("司"));
//        System.out.println(str.substring(0,str.indexOf("代理有限公司")));
//        System.out.println(str.charAt(str.indexOf("有限公司")-1));
//        System.out.println(str.substring(2,str.length()));
//        System.out.println(str.substring(0,str.indexOf("有限公司")+4));
//        System.out.println(str.substring(str.indexOf("理")+1,str.length()));
//        System.out.println(company.replace("21", "").contains(("[0-9]")));
//        System.out.println(isContainNumber(company.replace("21", "")));
        System.out.println(ClearBracket(company));

public static String ClearBracket(String company){
        String bracket = company.substring(company.indexOf("("),company.indexOf(")")+1);
        company = company.replace(bracket, "");
        return company;
    }
结果:
华厦世纪地产

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM