java一串数字去掉符号_如何删除除java中的空格或数字之外的所有标点符号

如何删除除Java中的空格或数字之外的所有标点符号。

"\\p{Punct}|\\d", "" //THIS WORKS BUT IT REMOVES THE NUMBERS AND I DONT WANT IT TO REMOVE THE NUMBERS...我正在阅读文字,我需要删除标点符号。

String[] internal;

char ch = 'a';

int counter = 1;

int count;

int c;

Map dictionary = new HashMap();

BufferedReader in = new BufferedReader(new FileReader("yu.txt"));

while (in.ready()) {

internal = (((in.readLine()).replaceAll("\\p{Punct}|\\d", "")).toLowerCase()).split(" ");//this does not work in my case cause it removes numbers... and makes them whitespaces but other than that this one works I JUST dont want it to remove numbers and keep whitespaces...

for (count = 0; count < internal.length; count++) {

if (!dictionary.containsKey(internal[count])) {

dictionary.put(internal[count], new HashSet());

}

if (dictionary.get(internal[count]).size()<10)

{

dictionary.get(internal[count]).add(counter);

}

}

counter++;

}

Iterator iterator = dictionary.keySet().iterator();

while (iterator.hasNext()) {

String key = iterator.next().toString();

String value = dictionary.get(key).toString();

System.out.println(key + ": " + value );

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值