String str = "本站提!!,供的程序?均为网上搜集,如果该程序涉\"及或侵'害到" +
"您的,,版权请立即写信通知我们。";
str = str.replaceAll("[\\pP]", "-"); //正则表达式
String[] arr = str.split("-");
str = "";
for(int i=0; i<arr.length; i++){
String temp = arr[i];
if("".equals(temp)) continue;
if(i==0){
str += temp.substring(temp.length()-1,temp.length());
}else{
str += temp.substring(0,1)+temp.substring(temp.length()-1,temp.length());
}
}
System.out.println(str);
\pP 其中的小写 p 是 property 的意思,表示 Unicode 属性,用于 Unicode 正表达式的前缀。
大写 P 表示 Unicode 字符集七个字符属性之一:标点字符。
其他六个是
L:字母;
M:标记符号(一般不会单独出现);
Z:分隔符(比如空格、换行等);
S:符号(比如数学符号、货币符号等);
N:数字(比如阿拉伯数字、罗马数字等);
C:其他字符
Java 判定标点符号
最新推荐文章于 2022-12-28 15:16:05 发布