读书人

剔除字符串中带中文的指定字符

发布时间: 2013-07-08 14:13:00 作者: rapoo

删除字符串中带中文的指定字符

public class Test {/** * @param args */public static void main(String[] args) {String mobile = "王二小(13112345678)";// 调用String endStr = removeStr(mobile);System.out.println("删除后结果:" + endStr);}public static String removeStr(String mobile) {String content = "张三(13312348888);王二小(13112345678);李四(13412345438);";System.out.println("删除前:" + content);System.out.println("删除内容:" + mobile);String subContent = "";if (!StringUtil.isBlank(content)) {mobile = mobile.replace("(", "\\(");mobile = mobile.replace(")", "\\)");subContent = content.replaceAll(";" + mobile + "|" + mobile + ";","");}return subContent;}}


删除前:张三(13312348888);王二小(13112345678);李四(13412345438);删除内容:王二小(13112345678)删除后结果:张三(13312348888);李四(13412345438);

读书人网 >行业软件

热点推荐