- class T {
- public static void main(String[] args) {
- String str = "!!!!去符号标号!!当然。!!..**半角" ;
- System.out.println(str);
- System.out.println(str.replaceAll( "\\p{Punct}" , "" ));\\替换半角
- System.out.println(str.replaceAll( "\\pP" , "" ));\\替换所有
- }
- }
本文展示了一个简单的Java程序,该程序演示了如何使用正则表达式来移除字符串中的标点符号。通过两个不同的方法实现了这一功能:一是仅移除半角标点,二是移除所有类型的标点符号。
806
4336

被折叠的 条评论
为什么被折叠?