本文介绍了如何删除字符串中的括号字符(java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用java删除字符串中所有类型的括号字符(例如:[],(),{})。

I want to remove all type of brackets character (example: [],(),{}) in string by using java.

我尝试使用此代码:

String test = "watching tv (at home)";
test = test.replaceAll("(","");
test = test.replaceAll(")","");

但它没有用,请帮帮我。

But it's not working, help me please.

推荐答案

删除包含所有括号,大括号和平方括号的所有标点符号...根据问题:

To remove all punctuation marks that include all brackets, braces and sq. brackets ... as per the question is:

String test = "watching tv (at home)";
test = test.replaceAll("\\p{P}","");

这篇关于如何删除字符串中的括号字符(java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:57
查看更多