`
jbeduhai
  • 浏览: 497245 次
  • 性别: Icon_minigender_1
  • 来自: 山东
社区版块
存档分类
最新评论

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

    博客分类:
  • java
 
阅读更多

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);



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics