我在电子邮件中有一条免责声明消息,我想使用Perl删除。
代码如下:
my $stval = 'hii This is a test Email*************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message.
******MAILEND***** End of Disclaimer ******MAILEND*****';
$stval =~ s/[*]//g; # this removes all * Characters
print "$stval\n\n";
我期待的输出应该如下:
hii This is a test Email
答案 0 :(得分:0)
那个标量字符串有几个嵌入\ n,好像它是一个here文档。您可以删除第一个' *'中的所有内容。到了字符串的末尾:
$stval =~ s/[*\n]+.+//g; # this removes all * Characters
答案 1 :(得分:-1)
使用s
修饰符在删除中包含换行符:
$stval =~ s/\*{10}.*//s;