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