如何使用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?
答案 0 :(得分:3)
use warnings;
use strict;
my $s = "foo\n bar goo\nber";
$s =~ s/\n\s*/ /g;
print "$s\n";
__END__
foo bar goo ber
答案 1 :(得分:2)
我不确定我是否理解你的问题。尝试:s{ \n\s+ }{ }gx