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; }
结果:
华厦世纪地产
转载注明出处
如果本文对你有帮助,请帮忙啦~~
打开支付宝首页搜“522901509”领红包,领到大红包的小伙伴赶紧使用哦!