Perl 将标点符号替换为一个空格

Perl 将标点符号替换为一个空格,perl,shell,unix,Perl,Shell,Unix,我使用这个命令列出文本中的所有标点符号 perl -CSD -nE '$seen{$1}++ while /(\pP)/g; END { say "$_ $seen{$_}" for keys %seen }' file.txt 如何将其替换为一个空格“” 比如说 Said Mr. Nkumbula last night: "We want to discuss what to do if the British Government gives in to Sir Roy and the

我使用这个命令列出文本中的所有标点符号

 perl -CSD -nE '$seen{$1}++ while /(\pP)/g; END { say "$_ $seen{$_}" for keys %seen }' file.txt
如何将其替换为一个空格“”

比如说

Said Mr. Nkumbula last night: "We want to discuss what to do
if the British Government gives in to Sir Roy and the talks fall
through. There are bound to be demonstrations."
将成为

Said Mr  Nkumbula last night   We want to discuss what to do
if the British Government gives in to Sir Roy and the talks fall
through  There are bound to be demonstrations  

你期望什么?备选方案:列出不需要的字符:

  sed -e 's/[.":;]/ /g' file.txt

“发音”没有意义。你是说标点符号吗?你能给我们一个小样本输入和预期输出吗?它正是你想要的。由于\pP涉及unicode,可能是区域设置问题。看看另一个选择。
  sed -e 's/[.":;]/ /g' file.txt