如何在Perl中删除换行符和空格并将它们替换为空白字符?

| 我如何用Perl编写一个正则表达式模式,它将像这样工作:
**If there is a new line**, after it, it will remove that new line character and all the whitespace characters after until it sees any character except for a white space character and will put just one whitespace character instead of them?
    
已邀请:
替代算子
use warnings;
use strict;

my $s = \"foo\\n    bar goo\\nber\";
$s =~ s/\\n\\s*/ /g;
print \"$s\\n\";

__END__

foo bar goo ber
    
我不确定我是否理解您的问题。尝试:
s{ \\n\\s+ }{ }gx
    

要回复问题请先登录注册